:root {
  color-scheme: light dark;
  --bg: #f6f7f9; --panel: #fff; --text: #16181d; --muted: #667085;
  --line: #d9dde3; --accent: #1f6feb; --mine: #e7f0ff; --danger: #c62828;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --panel: #181b21; --text: #e8eaee; --muted: #98a2b3;
    --line: #2a2f38; --accent: #5b9dff; --mine: #1b2a44; --danger: #ef6b6b;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
[hidden] { display: none !important; }

button, input, textarea { font: inherit; color: inherit; }
button {
  padding: .45rem .8rem; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel); cursor: pointer;
}
button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--danger); }
button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

#landing { max-width: 34rem; margin: 0 auto; padding: 18vh 1.25rem 0; }
#landing h1 { margin: 0 0 .5rem; font-size: 1.8rem; }
#landing p { color: var(--muted); margin: 0 0 1.25rem; }
#landing .primary { padding: .65rem 1.2rem; font-size: 1rem; }
.warn { color: var(--danger) !important; }

#chat { max-width: 48rem; height: 100dvh; margin: 0 auto; padding: .75rem; display: flex; flex-direction: column; gap: .6rem; }
header { display: flex; justify-content: space-between; align-items: center; gap: .75rem; flex-wrap: wrap; }
.title { display: flex; align-items: baseline; gap: .6rem; }
.status { color: var(--muted); font-size: .85rem; }
.status.ok::before { content: "● "; color: #2e9e5b; }
.status.off::before { content: "● "; color: var(--danger); }
.actions { display: flex; gap: .4rem; }
.notice { margin: 0; color: var(--muted); font-size: .82rem; }

#messages {
  flex: 1; min-height: 0; overflow-y: auto; list-style: none; margin: 0; padding: .75rem;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  display: flex; flex-direction: column; gap: .5rem;
}
#messages li { max-width: 85%; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 10px; align-self: flex-start; }
#messages li.mine { align-self: flex-end; background: var(--mine); }
#messages li.system { align-self: center; border: 0; color: var(--muted); font-size: .82rem; padding: 0; }
.meta { display: flex; align-items: center; gap: .5rem; color: var(--muted); font-size: .78rem; margin-bottom: .2rem; }
.meta button { margin-left: auto; padding: .1rem .45rem; font-size: .75rem; border-radius: 6px; }
.body { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 14px/1.4 ui-monospace, "Cascadia Mono", Consolas, monospace; }

#composer { display: grid; grid-template-columns: 9rem 1fr auto auto; gap: .5rem; align-items: end; }
#composer input, #composer textarea {
  width: 100%; padding: .5rem .65rem; background: var(--panel);
  border: 1px solid var(--line); border-radius: 8px; resize: none;
}
#composer textarea { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 14px; }
@media (max-width: 560px) {
  #composer { grid-template-columns: 1fr auto auto; }
  #composer input { grid-column: 1 / -1; }
}

.file { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .2rem; }
.file img { max-width: 100%; max-height: 320px; border-radius: 8px; align-self: flex-start; }
.file-row { display: flex; align-items: center; gap: .6rem; font-size: .85rem; overflow-wrap: anywhere; }
.file-row button { margin-left: auto; padding: .15rem .5rem; font-size: .78rem; border-radius: 6px; flex: none; }
#login { display: flex; gap: .5rem; margin: 0 0 1rem; }
#login input { flex: 1; min-width: 0; padding: .65rem .8rem; font-size: 1rem; background: transparent; border: 1px solid var(--line); border-radius: 8px; }
