/* VoIP Monkeys brand: navy room, banana yellow, monkey brown */
:root { --bg: #eef1f5; --card: #fff; --ink: #1b2430; --muted: #5d6878; --line: #dde2e9;
  --accent: #f4c430; --accent-ink: #1d1600; --link: #9a4f1a; --me: #f4c430; --me-ink: #1d1600; --them: #e4e8ee;
  --hdr: #1d2735; --hdr-ink: #eef2f7; --hdr-line: #2e3b4e;
  --ok-bg: #e7f6ec; --ok: #1d6b3a; --err-bg: #fdeceb; --err: #a52a21; color-scheme: light dark; }
@media (prefers-color-scheme: dark) { :root { --bg: #121821; --card: #1c2533; --ink: #e8ecf2; --muted: #98a3b3; --line: #2b3646;
  --link: #f4c430; --them: #273243; --hdr: #19212d;
  --ok-bg: #173323; --ok: #8be0a8; --err-bg: #3d1a18; --err: #ffaaa3; } }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--link); }
header.top { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; background: var(--hdr); color: var(--hdr-ink);
  border-bottom: 3px solid var(--accent); position: sticky; top: 0; z-index: 5; }
header .brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; letter-spacing: -.2px; text-decoration: none; color: var(--hdr-ink); }
header .brand img { width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--accent); image-rendering: pixelated; }
header .brand b { color: var(--accent); font-weight: 800; }
header.top nav a, header.top nav button.link { color: var(--hdr-ink); text-decoration: none; }
header.top nav a:hover, header.top nav button.link:hover { color: var(--accent); }
header nav { display: flex; gap: 14px; align-items: center; font-size: 14px; }
header nav form { margin: 0; }
main { max-width: 760px; margin: 0 auto; padding: 14px; }
main.narrow { max-width: 420px; padding-top: 24px; }
h1 { font-size: 24px; margin: 0 0 12px; } h2 { font-size: 18px; margin: 24px 0 8px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.flash { padding: 10px 14px; border-radius: 10px; margin: 0 0 12px; background: var(--ok-bg); color: var(--ok); }
.flash.err { background: var(--err-bg); color: var(--err); }
.stack { display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
input, select, textarea { font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; width: 100%; }
textarea { resize: vertical; }
button, .button { font: inherit; font-weight: 600; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer; text-decoration: none; display: inline-block; }
button.link { background: none; color: var(--link); padding: 0; font-weight: 400; }
.compose { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; margin-bottom: 12px; }
.compose summary { cursor: pointer; font-weight: 600; }
.compose form { margin-top: 12px; }
.filters a { display: inline-block; padding: 4px 10px; border-radius: 99px; background: var(--card); border: 1px solid var(--line);
  text-decoration: none; color: var(--ink); font-size: 13px; margin: 0 4px 6px 0; }
.filters a.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.threads { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.threads li + li { border-top: 1px solid var(--line); }
.threads a { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 12px 14px; text-decoration: none; color: var(--ink); }
.threads .who { font-weight: 600; } .threads .when { color: var(--muted); font-size: 13px; }
.threads .preview { grid-column: 1 / -1; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.threads .via { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.threads li.unread .preview { color: var(--ink); font-weight: 600; }
.count { background: var(--accent); color: var(--accent-ink); border-radius: 99px; font-size: 12px; padding: 0 7px; font-weight: 600; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
main.chat { display: flex; flex-direction: column; height: calc(100dvh - 56px); padding-bottom: 0; }
.chathead { padding: 4px 0 10px; font-size: 17px; }
.chathead .back { text-decoration: none; font-size: 26px; line-height: 1; margin-right: 6px; }
.msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 6px 2px 12px; }
.msg { max-width: 78%; display: flex; flex-direction: column; }
.msg.in { align-self: flex-start; } .msg.out { align-self: flex-end; align-items: flex-end; }
.msg .text { padding: 8px 12px; border-radius: 18px; background: var(--them); white-space: normal; overflow-wrap: anywhere; }
.msg.out .text { background: var(--me); color: var(--me-ink); } .msg.out .text a { color: inherit; }
.msg.failed .text { background: var(--err-bg); color: var(--err); }
.msg img { max-width: 240px; max-height: 320px; border-radius: 14px; display: block; margin-bottom: 4px; }
.msg .meta { font-size: 11px; color: var(--muted); margin: 2px 8px; }
.reply { display: flex; gap: 8px; align-items: flex-end; padding: 10px 0 max(10px, env(safe-area-inset-bottom)); background: var(--bg); }
.reply textarea { flex: 1; border-radius: 20px; min-height: 42px; max-height: 160px; }
.reply button { border-radius: 20px; }
.reply .attach { font-size: 22px; cursor: pointer; display: block; padding: 6px 2px; color: var(--ink); }
.reply .attach input { display: none; }
.reply .attach.has { color: var(--link); }
.msg.sending .text { opacity: .6; }
.msg form.retry { margin: 2px 8px 0; } .msg form.retry button { font-size: 12px; padding: 4px 12px; border-radius: 14px; background: var(--err); color: #fff; }

/* ---- phone ---- */
.callbtn { margin-left: auto; text-decoration: none; font-size: 20px; padding: 2px 8px; }
.top nav a.openphone { margin-right: 14px; }
body.phonebody { margin: 0; }
.phone { max-width: 380px; margin: 0 auto; padding: 12px 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.ph-top { display: flex; align-items: center; gap: 8px; }
.ph-line { flex: 1; font: inherit; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--card); color: var(--ink); }
.ph-status { margin-left: auto; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.ph-status .dot { width: 9px; height: 9px; border-radius: 50%; background: #bbb; display: inline-block; }
.ph-status.ok .dot { background: #1aa260; } .ph-status.warn .dot { background: #e0a100; } .ph-status.err .dot { background: #d93025; }
.ph-sound { background: #fff4d6; color: #6a4b00; border-radius: 10px; font-size: 14px; }
.ph-display { display: flex; align-items: center; gap: 6px; }
.ph-display input { flex: 1; font-size: 26px; text-align: center; border: 0; border-bottom: 2px solid var(--line); background: transparent; color: var(--ink); padding: 8px 4px; min-width: 0; }
.ph-display input:focus { outline: none; border-bottom-color: var(--accent); }
.ph-del { background: none; color: var(--muted); font-size: 22px; padding: 4px 8px; }
.ph-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; justify-items: center; margin: 6px 0; }
.ph-key { width: 72px; height: 72px; border-radius: 50%; background: var(--card); color: var(--ink); border: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 0; }
.ph-key b { font-size: 26px; font-weight: 500; line-height: 1; } .ph-key small { font-size: 9px; letter-spacing: 1px; color: var(--muted); margin-top: 2px; }
.ph-key:active { background: var(--them); }
.ph-call, .ph-hang { width: 68px; height: 68px; border-radius: 50%; font-size: 28px; align-self: center; padding: 0; }
.ph-call { background: #1aa260; } .ph-hang { background: #d93025; transform: rotate(135deg); }
.ph-msg { text-align: center; color: var(--err, #d93025); min-height: 1.2em; margin: 0; font-size: 14px; }
.ph-h { margin: 6px 0 0; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.ph-recent { list-style: none; margin: 0; padding: 0; max-height: 200px; overflow: auto; }
.ph-recent li { display: flex; gap: 8px; padding: 7px 4px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 15px; }
.ph-recent li .t { margin-left: auto; color: var(--muted); font-size: 12px; } .ph-recent li .dir { color: var(--muted); }
.ph-who-label { text-align: center; color: var(--muted); margin: 30px 0 0; }
.ph-who { text-align: center; font-size: 24px; margin: 8px 0 0; }
.ph-state { text-align: center; color: var(--muted); margin: 4px 0 16px; font-variant-numeric: tabular-nums; }
.ph-row { display: flex; justify-content: center; gap: 14px; margin: 18px 0; }
.ph-green, .ph-red { min-width: 120px; padding: 14px; border-radius: 30px; font-size: 17px; }
.ph-green { background: #1aa260; color: #fff; } .ph-red { background: #d93025; color: #fff; }
.ph-tool { background: var(--card); color: var(--ink); border: 1px solid var(--line); min-width: 110px; }
.ph-tool.on { background: var(--ink); color: var(--bg); }

/* ---- brand: sign-in pages and footer ---- */
.hero { display: block; width: 100%; max-width: 190px; height: auto; margin: 0 auto 16px; border-radius: 18px; box-shadow: 0 6px 24px rgba(10, 16, 26, .35); }
footer.site { text-align: center; color: var(--muted); font-size: 12px; padding: 18px 16px 24px; }
footer.site a { color: var(--muted); }
main.chat + footer.site { display: none; }
@media (max-width: 440px) { header .brand { font-size: 16px; gap: 8px; } header .brand img { width: 30px; height: 30px; } header nav { gap: 10px; } .top nav a.openphone { margin-right: 0; } }
