:root {
  --bg: #ffffff;
  --list-bg: #f5f5f5;
  --card: #ffffff;
  --text: #000000;
  --muted: #8e8e93;
  --line: #e5e5e5;
  --accent: #0099ff;         /* Conversations-ish blue */
  --out-bubble: #3390ec;
  --in-bubble: #f1f0f0;
  --header: #f5f5f5;
  --input-bg: #ffffff;
  --send: #4caf50;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--text);
}

/* Login */
.login { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; padding: 24px; gap: 12px; text-align: center; }
.login h1 { font-weight: 600; font-size: 26px; }
.login .sub { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.login input { width: 100%; max-width: 320px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; font-size: 16px; background: var(--input-bg); color: var(--text); }
.login button { width: 100%; max-width: 320px; padding: 13px; background: var(--accent); color: #fff; border: 0; border-radius: 10px; font-size: 16px; cursor: pointer; }
.login #status { color: var(--muted); font-size: 13px; min-height: 18px; }

/* App shell */
.app { display: flex; flex-direction: column; height: 100%; }

/* Chat list */
.list { flex: 1; display: flex; flex-direction: column; }
.list header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; background: var(--header); border-bottom: 1px solid var(--line); }
.list header span { font-weight: 600; font-size: 18px; }
.roster-empty { color: var(--muted); text-align: center; padding: 30px 16px; font-size: 14px; }
.ghost { border: 0; background: none; color: var(--accent); font-size: 14px; cursor: pointer; }
.roster { flex: 1; overflow-y: auto; background: var(--list-bg); }
.roster-item { display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); cursor: pointer; }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 600; flex-shrink: 0; }
.roster-meta { min-width: 0; }
.rname { font-weight: 500; font-size: 16px; }
.rsub { color: var(--muted); font-size: 13px; }

/* Chat thread */
.chat { flex: 1; display: flex; flex-direction: column; }
.chat header { display: flex; align-items: center; gap: 8px; padding: 12px 14px; background: var(--header); border-bottom: 1px solid var(--line); }
.chat header .back { border: 0; background: none; font-size: 26px; cursor: pointer; color: var(--accent); }
.chat header #chat-title { font-weight: 600; font-size: 17px; flex: 1; }
.chat header .online-status { color: var(--muted); font-size: 12px; }
.messages { flex: 1; display: flex; flex-direction: column; overflow-y: auto; padding: 12px; background: var(--bg); }
.msg-row:first-child { margin-top: auto; }
.msg-row { display: flex; margin-bottom: 8px; }
.msg-row.out { justify-content: flex-end; }
.bubble { max-width: 75%; padding: 8px 12px; border-radius: 18px; font-size: 15px; line-height: 1.35; position: relative; word-break: break-word; }
.bubble.image { padding: 3px; }
.bubble.image img { max-width: 240px; max-height: 240px; border-radius: 16px; display: block; }
.msg-row.in .bubble { background: var(--in-bubble); color: var(--text); border-bottom-left-radius: 4px; }
.msg-row.out .bubble { background: var(--out-bubble); color: #fff; border-bottom-right-radius: 4px; }
.time { font-size: 10px; opacity: .7; text-align: right; margin-top: 2px; display: flex; justify-content: flex-end; align-items: center; gap: 3px; }
.tick { font-size: 12px; line-height: 1; }
.tick.sent { color: rgba(255,255,255,.85); }
.tick.delivered { color: #8fd0ff; }

/* Composer */
.composer { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--line); background: var(--card); }
.attach { font-size: 22px; cursor: pointer; padding: 6px; flex-shrink: 0; }
#msg-input { flex: 1; min-width: 0; padding: 10px 14px; border: 1px solid var(--line); border-radius: 20px; font-size: 15px; background: var(--input-bg); color: var(--text); }
#send-btn { padding: 10px 16px; background: var(--send); color: #fff; border: 0; border-radius: 20px; font-size: 15px; cursor: pointer; flex-shrink: 0; }

.st-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.st-dot.on { background: #4caf50; }
.st-dot.off { background: #c4c4c4; }

/* Dark theme */
html[data-theme="dark"] {
  --bg: #1a1a1a;
  --list-bg: #1f1f1f;
  --card: #242424;
  --text: #e8e8e8;
  --muted: #9a9a9a;
  --line: #2e2e2e;
  --accent: #3390ec;
  --out-bubble: #3390ec;
  --in-bubble: #2b2b2b;
  --header: #1f1f1f;
  --input-bg: #242424;
  --send: #4caf50;
}
.login 
.login input::placeholder, #msg-input::placeholder { color: var(--muted); }
