:root {
  color-scheme: light dark;
  --bg: #f4f5f7;
  --paper: #ffffff;
  --text: #1e2934;
  --muted: #485766;
  --line: #cbd2d9;
  --accent: #1c5b52;
  --own: #e0f1ed;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171a1e;
  --paper: #252930;
  --text: #eef1f5;
  --muted: #bdc7d3;
  --line: #56616f;
  --accent: #a8e0d5;
  --own: #25413e;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #171a1e;
    --paper: #252930;
    --text: #eef1f5;
    --muted: #bdc7d3;
    --line: #56616f;
    --accent: #a8e0d5;
    --own: #25413e;
  }
}
[hidden] { display: none !important; }
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1rem/1.55 system-ui, sans-serif;
}
main { max-width: 48rem; margin-inline: auto; padding: 1rem clamp(1rem, 4vw, 2rem) 2rem; }
header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
h1 { font-size: 1.65rem; margin: .2rem 0 .7rem; }
#actions { display: flex; gap: .5rem; }
#status { color: var(--muted); min-height: 1.5em; margin-block: .7rem; }
#login, #settings, #send { background: var(--paper); border: 1px solid var(--line); border-radius: .75rem; padding: 1rem; }
#login { max-width: 28rem; margin-inline: auto; }
#login h2, #settings h2 { margin-top: 0; }
label { display: grid; gap: .3rem; margin-block: .65rem; }
input, select, textarea, button { font: inherit; }
input, select, textarea { color: var(--text); background: var(--paper); border: 1px solid var(--line); border-radius: .4rem; padding: .55rem; width: 100%; }
textarea { resize: vertical; }
button { color: var(--accent); background: var(--paper); border: 1px solid var(--line); border-radius: .4rem; padding: .45rem .75rem; cursor: pointer; }
button:disabled { opacity: .65; cursor: wait; }
#messages { display: grid; gap: .65rem; padding: 0; list-style: none; }
#messages li { background: var(--paper); border: 1px solid var(--line); border-radius: .65rem; padding: .55rem .75rem; width: fit-content; max-width: 95%; min-width: 0; }
#messages li[data-own] { justify-self: end; background: var(--own); }
#messages h3 { font-size: .85rem; margin: 0; color: var(--muted); }
#messages p { white-space: pre-wrap; overflow-wrap: anywhere; margin: .35rem 0; }
#messages button { font-size: .8rem; }
#send { margin-block: 1rem; }
