:root {
  --bg: #0b0b0c; --panel: #141416; --line: #26262a; --text: #ececf0; --muted: #8b8b93;
  --user: #1f1f24; --accent: #f4f4f5; --accent-ink: #0b0b0c; --ok: #3fb96b; --bad: #e5534b; --warn: #d6a33a;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #fbfbfc; --panel: #f1f1f3; --line: #dedee3; --text: #18181b; --muted: #6b6b74;
    --user: #e9e9ee; --accent: #18181b; --accent-ink: #fbfbfc;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif; }
button { font: inherit; color: inherit; cursor: pointer; }

.gate { display: grid; place-items: center; min-height: 100%; padding: 16px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 32px; max-width: 360px; width: 100%; text-align: center; }
.card h1 { margin: 0 0 8px; font-size: 22px; }
.card p { color: var(--muted); margin: 0 0 24px; }
.btn { display: inline-block; background: var(--accent); color: var(--accent-ink); text-decoration: none; padding: 10px 18px; border-radius: 999px; font-weight: 600; }

.app { display: flex; height: 100%; }
.side { width: 260px; flex: none; background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 12px; gap: 8px; }
.new { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px; padding: 9px 14px; font-weight: 600; text-align: left; }
.threads { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.threads button { background: none; border: 0; text-align: left; padding: 8px 10px; border-radius: 8px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.threads button:hover { background: var(--user); color: var(--text); }
.threads button.on { background: var(--user); color: var(--text); }
.threads button.busy::after { content: " •"; color: var(--warn); }
.me { border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.email { overflow: hidden; text-overflow: ellipsis; }
.link { background: none; border: 0; padding: 0; color: var(--muted); text-align: left; text-decoration: underline; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--line); min-height: 48px; }
.menu { display: none; background: none; border: 0; font-size: 20px; padding: 0 4px; }
.title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conn { width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
.conn.live { background: var(--ok); }

.log { flex: 1; overflow-y: auto; padding: 24px 16px; display: flex; flex-direction: column; gap: 14px; }
.log > * { width: 100%; max-width: 760px; margin: 0 auto; }
.empty { margin: auto; text-align: center; color: var(--muted); }
.empty h1 { font-size: 28px; font-weight: 600; color: var(--text); }
.msg { white-space: normal; overflow-wrap: anywhere; }
.msg p { margin: 0 0 10px; }
.msg p:last-child { margin-bottom: 0; }
.msg.user { background: var(--user); border-radius: 18px; padding: 10px 14px; width: auto; max-width: min(760px, 85%); margin-right: max(0px, calc((100% - 760px) / 2)); align-self: flex-end; white-space: pre-wrap; }
.msg.notice { color: var(--muted); font-size: 13px; white-space: pre-wrap; border-left: 2px solid var(--line); padding-left: 10px; }
.msg.error { color: var(--bad); white-space: pre-wrap; }
.msg pre { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; overflow-x: auto; white-space: pre; }
.msg code { font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.msg :not(pre) > code { background: var(--panel); padding: 1px 5px; border-radius: 5px; }
.msg a { color: inherit; }
.confirm { border: 1px solid var(--warn); border-radius: 14px; padding: 12px 14px; background: var(--panel); }
.confirm h2 { font-size: 14px; margin: 0 0 8px; }
.confirm pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0 0 10px; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.confirm .why { color: var(--muted); font-size: 13px; margin: 0 0 10px; }
.confirm .acts { display: flex; gap: 8px; flex-wrap: wrap; }
.confirm button { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 6px 14px; }
.confirm button.ok { border-color: var(--ok); }
.confirm button.no { border-color: var(--bad); }
.dots { color: var(--muted); }
.dots::after { content: "…"; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .2; } }

.composer { padding: 0 16px 16px; }
.composer > * { max-width: 760px; margin: 0 auto; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.chips span { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: 13px; }
.box { display: flex; align-items: flex-end; gap: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 24px; padding: 8px 8px 8px 14px; }
.attach { cursor: pointer; padding: 6px 2px; }
.attach input { display: none; }
textarea { flex: 1; resize: none; border: 0; outline: 0; background: none; color: var(--text); font: inherit; max-height: 200px; padding: 6px 0; }
.send { width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; flex: none; }
.send:disabled { opacity: .35; cursor: default; }

@media (max-width: 760px) {
  .side { position: fixed; inset: 0 auto 0 0; z-index: 10; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; }
  .menu { display: block; }
  .msg.user { max-width: 90%; margin-right: 0; }
}
