:root {
  --bg: #0d0f14;
  --panel: #151821;
  --panel-2: #1c2030;
  --line: #262b3b;
  --text: #e7e9ef;
  --muted: #8b91a3;
  --accent: #7c8cff;
  --ok: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --milo: #f5a524;
  --claude: #e07a5f;
  --dave: #60a5fa;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

button, input, textarea { font: inherit; color: inherit; }

.login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.login-card {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.login-card h1 { margin: 0; font-size: 22px; }
.login-card p { margin: 0; color: var(--muted); font-size: 14px; }
.login-mark {
  width: 44px; height: 44px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--accent); color: #0d0f14; font-weight: 800; font-size: 20px;
}
.login-card input {
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px;
  padding: 11px 12px; outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button, .send {
  background: var(--accent); color: #0d0f14; border: 0; border-radius: 10px;
  padding: 10px 16px; font-weight: 700; cursor: pointer;
}
.login-card button:disabled, .send:disabled { opacity: .5; cursor: default; }
.login-error, .composer-error { color: var(--bad); font-size: 13px; min-height: 0; margin: 0; }
.login-error:empty, .composer-error:empty { display: none; }

.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 980px;
  margin: 0 auto;
  position: relative;
}

.top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
  flex-wrap: wrap;
}
.title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.room-name { font-weight: 700; }
.conn { color: var(--muted); font-size: 13px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--warn); flex: none; }
.dot.on { background: var(--ok); }
.dot.off { background: var(--bad); }
.people { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }
.person {
  display: flex; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 3px 10px 3px 6px; font-size: 13px; white-space: nowrap;
}
.person .pavatar {
  width: 20px; height: 20px; border-radius: 50%; overflow: hidden; flex: none;
  display: grid; place-items: center; font-size: 11px; font-weight: 800; color: #0d0f14; background: #4b5163;
  box-shadow: 0 0 0 2px #4b5163; opacity: .7;
}
.person.online .pavatar { box-shadow: 0 0 0 2px var(--ok); opacity: 1; }
.person .pavatar img, .avatar img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: inherit; }
.person { padding-left: 4px; }
.person .ago { color: var(--muted); font-size: 12px; }
.ghost {
  background: transparent; border: 1px solid var(--line); border-radius: 8px;
  padding: 5px 10px; font-size: 13px; color: var(--muted); cursor: pointer;
}
.ghost:hover { color: var(--text); }

.scroller {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 8px;
  overscroll-behavior: contain;
}
.older {
  display: block; margin: 4px auto 12px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 14px; font-size: 13px; color: var(--muted); cursor: pointer;
}
.messages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.empty { color: var(--muted); text-align: center; margin-top: 30vh; }

.day {
  text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0 8px;
  display: flex; align-items: center; gap: 10px;
}
.day::before, .day::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.msg { display: grid; grid-template-columns: 36px 1fr; gap: 10px; padding: 6px 8px; border-radius: 10px; }
.msg:hover { background: rgba(255, 255, 255, .025); }
.msg.cont { padding-top: 0; }
.msg.cont .avatar { visibility: hidden; height: 0; }
.msg.cont .meta { display: none; }
.avatar {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 800; color: #0d0f14; font-size: 15px; overflow: hidden;
}
.from-milo .avatar { background: var(--milo); }
.from-claude .avatar { background: var(--claude); }
.from-dave .avatar { background: var(--dave); }
.meta { display: flex; align-items: baseline; gap: 8px; }
.name { font-weight: 700; }
.from-milo .name { color: var(--milo); }
.from-claude .name { color: var(--claude); }
.from-dave .name { color: var(--dave); }
.time { color: var(--muted); font-size: 12px; }
.body { min-width: 0; overflow-wrap: anywhere; }
.body p { margin: 0 0 6px; }
.body p:last-child { margin-bottom: 0; }
.body ul, .body ol { margin: 4px 0 6px; padding-left: 22px; }
.body h3, .body h4 { margin: 8px 0 4px; font-size: 15px; }
.body blockquote { margin: 4px 0; padding: 2px 10px; border-left: 3px solid var(--line); color: var(--muted); }
.body code {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px;
  padding: 0 4px; font: 13px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.body pre {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; overflow-x: auto; margin: 4px 0 6px;
}
.body pre code { background: none; border: 0; padding: 0; white-space: pre; }
.body a { color: var(--accent); }
.shot { display: inline-block; margin-top: 6px; max-width: min(100%, 520px); }
.shot img {
  display: block; max-width: 100%; max-height: 420px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel); cursor: zoom-in;
}
.shot .dl { font-size: 12px; color: var(--muted); text-decoration: none; display: block; margin-top: 3px; width: max-content; }
.shot .dl:hover { color: var(--text); }
.msg.pending { opacity: .55; }

.jump {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 96px;
  background: var(--accent); color: #0d0f14; border: 0; border-radius: 999px;
  padding: 6px 14px; font-weight: 700; font-size: 13px; cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .45);
}
.typing { color: var(--muted); font-size: 12px; padding: 0 18px; height: 18px; }

.composer {
  border-top: 1px solid var(--line);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--bg);
}
.composer .row { display: flex; align-items: flex-end; gap: 8px; }
.scroller, .composer textarea { scrollbar-width: thin; scrollbar-color: #2a2f40 transparent; }
.composer textarea {
  flex: 1; resize: none; max-height: 180px; min-height: 42px; overflow-y: hidden;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; outline: none;
}
.composer textarea:focus { border-color: var(--accent); }
.composer.drag textarea { border-color: var(--accent); border-style: dashed; }
.attach {
  width: 42px; height: 42px; flex: none; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; cursor: pointer; color: var(--muted);
}
.attach:hover { color: var(--text); }
.send { height: 42px; }
.attach-preview { position: relative; display: inline-block; margin-bottom: 8px; }
.attach-preview img { max-height: 110px; max-width: 220px; border-radius: 8px; border: 1px solid var(--line); display: block; }
.attach-preview .remove {
  position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel-2); cursor: pointer; line-height: 1;
}

.viewer {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .88); display: grid; place-items: center;
  z-index: 10; padding: 16px; cursor: zoom-out;
}
.viewer img { max-width: 100%; max-height: 100%; border-radius: 8px; }

@media (max-width: 640px) {
  .top { padding: 8px 12px; gap: 8px; }
  .people { order: 3; width: 100%; margin-left: 0; }
  .person .ago { display: none; }
  .scroller { padding: 8px 10px; }
  .composer { padding-left: 10px; padding-right: 10px; }
  .msg { grid-template-columns: 30px 1fr; gap: 8px; padding: 5px 4px; }
  .avatar { width: 30px; height: 30px; font-size: 13px; border-radius: 8px; }
  .jump { bottom: 92px; }
}
