/* Client app styles. Colours come from each client's settings. */
:root {
  --brand: #0B4F4A; --accent: #34C08A; --bg: #F5F2E9; --ink: #0E1E1C;
  --card: #ffffff; --line: rgba(14, 30, 28, 0.12); --muted: rgba(14, 30, 28, 0.62);
  --in: #ffffff; --danger: #B3261E;
  --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; -webkit-text-size-adjust: 100%; min-height: 100vh; }
a { color: var(--brand); }
main { padding: 12px 16px calc(24px + var(--safe-b)); max-width: 640px; margin: 0 auto; }
button, input, textarea { font: inherit; }

.bar { position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: 72px 1fr 72px; align-items: center;
  padding: calc(8px + var(--safe-t)) 8px 8px; background: var(--brand); color: #fff; }
.bar h1 { margin: 0; font-size: 17px; font-weight: 600; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-r { display: flex; justify-content: flex-end; }
.iconbtn { display: inline-flex; width: 44px; height: 44px; align-items: center; justify-content: center; color: #fff; border-radius: 22px; }
.callbtn { display: inline-flex; gap: 6px; align-items: center; height: 36px; padding: 0 14px; border: 0; border-radius: 18px; background: var(--accent); color: var(--ink); font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin: 12px 0; }
.card p { margin: 6px 0 0; color: var(--muted); }
.card ol { margin: 8px 0 0; padding-left: 20px; color: var(--muted); }
.card ol li { margin: 4px 0; }
.hint { border-color: var(--accent); }
.hint .btn { margin-top: 12px; }
.btn { display: block; width: 100%; min-height: 48px; border: 0; border-radius: 12px; background: var(--brand); color: #fff; font-weight: 600; font-size: 16px; margin-top: 12px; }
.btn:disabled { opacity: 0.6; }
.btn.ghost { background: transparent; color: var(--brand); border: 1px solid var(--line); }
.btn.danger { color: var(--danger); }
.link { background: none; border: 0; color: var(--brand); padding: 12px 0 0; text-decoration: underline; }
.err { color: var(--danger); min-height: 1em; margin: 8px 0 0; }

.signin { text-align: center; padding-top: calc(48px + var(--safe-t)); }
.signin .logo { width: 88px; height: 88px; border-radius: 20px; box-shadow: 0 2px 10px rgba(0,0,0,0.12); }
.signin h1 { margin: 16px 0 4px; font-size: 26px; }
.signin .sub { margin: 0 0 8px; color: var(--muted); }
.signin form { text-align: left; }
.signin label { display: block; font-weight: 600; margin-bottom: 8px; }
.signin input { width: 100%; height: 52px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; font-size: 20px; letter-spacing: 0.04em; background: #fff; }

.threads { list-style: none; margin: 4px 0 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: block; padding: 14px 16px; color: inherit; text-decoration: none; min-height: 64px; }
.threads a:active { background: rgba(0,0,0,0.04); }
.row1, .row2 { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.name { font-weight: 600; }
.unread .name::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 5px; background: var(--accent); margin-right: 8px; vertical-align: 1px; }
.time { color: var(--muted); font-size: 13px; white-space: nowrap; }
.prev { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; min-width: 0; }
.dot { background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center; }
.empty { color: var(--muted); text-align: center; padding: 32px 16px; }

.thread { padding-bottom: calc(96px + var(--safe-b)); }
.phone { text-align: center; color: var(--muted); margin: 4px 0 12px; font-size: 14px; }
.items { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 82%; padding: 10px 12px; border-radius: 16px; background: var(--in); border: 1px solid var(--line); align-self: flex-start; word-wrap: break-word; }
.msg.out { align-self: flex-end; background: var(--brand); color: #fff; border-color: var(--brand); }
.msg.out.auto { background: #fff; color: var(--ink); border: 1px dashed var(--brand); }
.msg .who { font-size: 12px; opacity: 0.75; margin-bottom: 4px; }
.msg .text { white-space: pre-wrap; }
.msg .st { font-size: 12px; opacity: 0.75; margin-top: 4px; text-align: right; }
.photo { display: block; max-width: 100%; max-height: 320px; border-radius: 10px; margin-top: 6px; }
.event { align-self: stretch; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.event.call_missed, .event.voicemail { border-left: 4px solid var(--accent); }
.ev-t { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.ev-t .time { margin-left: auto; font-weight: 400; }
.event .sum { margin-top: 6px; }
.event .st { color: var(--muted); font-size: 13px; margin-top: 4px; }
.event audio { width: 100%; margin-top: 8px; }
.event details { margin-top: 6px; color: var(--muted); }
.event details p { margin: 6px 0 0; color: var(--ink); white-space: pre-wrap; }
.personal { display: flex; gap: 8px; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; margin: 20px 0 0; }

.composer { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px calc(8px + var(--safe-b)); background: var(--bg); border-top: 1px solid var(--line); }
.composer textarea { flex: 1; min-height: 44px; max-height: 140px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 22px; resize: none; background: #fff; font-size: 16px; }
.composer .send { width: auto; min-height: 44px; margin: 0; padding: 0 18px; border-radius: 22px; }
.composer.note { justify-content: center; color: var(--muted); font-size: 14px; padding-top: 14px; }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(88px + var(--safe-b)); z-index: 20; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px; text-align: center; }

.ico { display: inline-block; width: 18px; height: 18px; background: currentColor; -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; flex: none; }
.ico-back { width: 22px; height: 22px; --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M15 4l-8 8 8 8' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.ico-gear { width: 22px; height: 22px; --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='12' r='3.2' fill='none' stroke='black' stroke-width='2'/%3E%3Cpath d='M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1' stroke='black' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E"); }
.ico-call { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.6 10.8a15.1 15.1 0 006.6 6.6l2.2-2.2a1 1 0 011-.25 11.4 11.4 0 003.6.57 1 1 0 011 1V20a1 1 0 01-1 1A17 17 0 013 4a1 1 0 011-1h3.5a1 1 0 011 1c0 1.25.2 2.45.57 3.57a1 1 0 01-.25 1z' fill='black'/%3E%3C/svg%3E"); }
.ico-missed { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M3 7l6 6 4-4 6 6M19 11v4h-4' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }
.ico-vm { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='6.5' cy='12' r='3.5' fill='none' stroke='black' stroke-width='2'/%3E%3Ccircle cx='17.5' cy='12' r='3.5' fill='none' stroke='black' stroke-width='2'/%3E%3Cpath d='M6.5 15.5h11' stroke='black' stroke-width='2'/%3E%3C/svg%3E"); }
.ico-photo { --m: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='3' y='5' width='18' height='14' rx='2' fill='none' stroke='black' stroke-width='2'/%3E%3Ccircle cx='9' cy='10' r='2' fill='black'/%3E%3Cpath d='M4 18l5-5 4 4 3-3 4 4' fill='none' stroke='black' stroke-width='2'/%3E%3C/svg%3E"); }

/* Full-size photo viewer */
.viewer { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.92); display: flex; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 56px) 12px calc(env(safe-area-inset-bottom) + 12px); }
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }
.viewer-close { position: absolute; top: calc(env(safe-area-inset-top) + 10px); right: 12px; min-height: 44px; padding: 0 18px;
  border: 0; border-radius: 22px; background: #fff; color: #111; font: 600 16px/1 system-ui, sans-serif; }
.photo { cursor: zoom-in; }
