/* The `hidden` attribute must win over the display rules below (they would otherwise override it). */
[hidden] { display: none !important; }
:root { color-scheme: light dark; font-family: system-ui, sans-serif; --brand: #1f4e79; --line: #8884; }
* { box-sizing: border-box; }
body { margin: 0; height: 100vh; }
.center { display: grid; place-items: center; align-content: center; gap: 0.5rem; height: 100vh; text-align: center; }
.muted { opacity: 0.7; }
.small { font-size: 0.85rem; }
.error { color: #c0392b; }
.button { display: inline-block; padding: 0.55rem 1.1rem; border-radius: 0.4rem; border: 0;
  background: var(--brand); color: #fff; text-decoration: none; font: inherit; cursor: pointer; }
.button:disabled { opacity: 0.5; cursor: default; }
.button.wide { width: 100%; }
.link { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; padding: 0; font: inherit; }
#app { display: grid; grid-template-columns: 16rem 1fr; height: 100vh; }
aside { border-right: 1px solid var(--line); padding: 0.75rem; display: flex; flex-direction: column; gap: 0.75rem; min-height: 0; }
#conversations { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 0.25rem; }
.conv { text-align: left; background: none; border: 0; padding: 0.45rem 0.5rem; border-radius: 0.3rem; color: inherit;
  font: inherit; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv:hover, .conv.active { background: #8882; }
.me { display: grid; gap: 0.25rem; border-top: 1px solid var(--line); padding-top: 0.5rem; }
main { display: flex; flex-direction: column; min-height: 0; padding: 0.75rem 1rem; gap: 0.5rem; }
header { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.banner { padding: 0.5rem 0.75rem; border-radius: 0.4rem; background: #f39c1233; }
#messages { flex: 1; overflow-y: auto; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.75rem; }
#messages li { max-width: 48rem; padding: 0.6rem 0.8rem; border-radius: 0.6rem; }
#messages li.user { align-self: flex-end; background: #1f4e7933; }
#messages li.assistant { align-self: flex-start; background: #8881; }
#messages li.failed { outline: 1px solid #c0392b88; }
.text { overflow-wrap: anywhere; }
#composer { display: flex; gap: 0.5rem; align-items: flex-end; }
#composer textarea { flex: 1; font: inherit; padding: 0.5rem; border-radius: 0.4rem; border: 1px solid var(--line); resize: vertical; }
@media (max-width: 700px) { #app { grid-template-columns: 1fr; } aside { display: none; } }
#messages li.pending .text { opacity: 0.6; font-style: italic; }
.text p { margin: 0 0 0.5rem 0; }
.text p:last-child { margin-bottom: 0; }
.text ul, .text ol { margin: 0.25rem 0 0.5rem 1.25rem; padding: 0; }
.text h4 { margin: 0.5rem 0 0.25rem 0; }
.text pre { background: #8882; padding: 0.5rem; border-radius: 0.3rem; overflow-x: auto; white-space: pre; }
.text code { font-family: ui-monospace, monospace; font-size: 0.9em; }
#messages li.user .text { white-space: pre-wrap; }
.sources { margin-top: 0.5rem; border-top: 1px solid var(--line); padding-top: 0.4rem; }
.sources .provenance { font-weight: 600; opacity: 0.8; }
.sources ol { margin: 0.25rem 0 0 1.1rem; padding: 0; }
.sources a { color: inherit; }
.files { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.file-card { display: inline-flex; gap: 0.25rem; align-items: baseline; padding: 0.45rem 0.7rem; border: 1px solid var(--line);
  border-radius: 0.4rem; color: inherit; text-decoration: none; }
.file-card:hover { background: #8882; }
.button.secondary { background: transparent; color: inherit; border: 1px solid var(--line); }
.attachments { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chip { padding: 0.25rem 0.6rem; border-radius: 1rem; font-size: 0.85rem; border: 1px solid var(--line); }
.chip.ok { border-color: #27ae60; } .chip.wait { opacity: 0.8; } .chip.bad { border-color: #c0392b; color: #c0392b; }
