:root {
  --green: #008069; --green-d: #005c4b; --bg: #efeae2; --panel: #fff; --text: #111b21; --muted: #667781;
  --line: #e9edef; --bubble-in: #fff; --bubble-out: #d9fdd3; --blue: #53bdeb; --warn: #e9a23b; --err: #d93025;
  --radius: 10px; font-synthesis: none;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0b141a; --panel: #111b21; --text: #e9edef; --muted: #8696a0; --line: #222d34;
          --bubble-in: #202c33; --bubble-out: #005c4b; --green: #00a884; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--green); }
button { font: inherit; cursor: pointer; }
#shell { display: flex; flex-direction: column; height: 100dvh; max-width: 900px; margin: 0 auto; background: var(--panel); }
#top { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--green); color: #fff;
  padding-top: max(10px, env(safe-area-inset-top)); }
#top h1 { font-size: 18px; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon { background: none; border: 0; color: inherit; font-size: 22px; padding: 0 6px; }
#view { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
#tabs { display: flex; border-top: 1px solid var(--line); background: var(--panel); padding-bottom: env(safe-area-inset-bottom); }
#tabs a { flex: 1; text-align: center; padding: 8px 0 6px; color: var(--muted); text-decoration: none; font-size: 12px; position: relative; }
#tabs a span { display: block; font-size: 20px; line-height: 1.2; }
#tabs a.active { color: var(--green); font-weight: 600; }
#tabs b { position: absolute; top: 4px; left: 55%; background: var(--green); color: #fff; border-radius: 10px;
  font-size: 11px; padding: 0 6px; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; min-width: 0; }
.list li > .btn { flex: none; }
.list li.nolink { cursor: default; flex-wrap: wrap; }
.list li:hover { background: rgba(0,0,0,.03); }
.avatar { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 20px;
  background: #dfe5e7; flex: none; color: #54656f; }
.avatar.friend { background: #c8e6c9; } .avatar.company { background: #ffe0b2; }
.li-main { flex: 1; min-width: 0; }
.li-top { display: flex; justify-content: space-between; gap: 8px; }
.li-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li-sub { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.time { color: var(--muted); font-size: 12px; flex: none; }
.chat { background: var(--bg); min-height: 100%; padding: 10px 10px 80px; display: flex; flex-direction: column; gap: 6px; }
.bubble { max-width: 85%; background: var(--bubble-in); padding: 8px 10px 6px; border-radius: var(--radius);
  box-shadow: 0 1px .5px rgba(0,0,0,.13); align-self: flex-start; word-wrap: break-word; }
.bubble.out { background: var(--bubble-out); align-self: flex-end; }
.bubble .meta { display: flex; justify-content: flex-end; gap: 6px; align-items: center; color: var(--muted); font-size: 11px; margin-top: 4px; }
.bubble .kind { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.bubble .body { white-space: pre-wrap; }
.bubble.entry { cursor: pointer; }
.ticks { font-size: 12px; letter-spacing: -3px; color: var(--muted); }
.ticks.blue { color: var(--blue); } .ticks.warn { color: var(--warn); letter-spacing: 0; }
.note { display: inline-block; border-radius: 6px; padding: 0 6px; font-size: 11px; font-weight: 600; background: #e7f6ec; color: #1e7b34; }
.note.n3, .note.n4 { background: #fff4e0; color: #9a5b00; } .note.n5, .note.n6 { background: #fde7e7; color: var(--err); }
.pill { font-size: 11px; padding: 1px 8px; border-radius: 10px; background: var(--line); color: var(--muted); }
.pill.warn { background: var(--warn); color: #000; }
.composer { position: sticky; bottom: 0; display: flex; gap: 8px; padding: 8px; background: var(--panel); border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; border-radius: 20px; border: 1px solid var(--line); padding: 9px 14px;
  font: inherit; background: var(--panel); color: var(--text); max-height: 120px; }
.btn { background: var(--green); color: #fff; border: 0; border-radius: 20px; padding: 9px 16px; font-weight: 600; text-decoration: none; display: inline-block; text-align: center; }
.btn.ghost { background: transparent; color: var(--green); border: 1px solid var(--green); }
.btn.danger { background: var(--err); }
.btn.small { padding: 4px 12px; font-size: 13px; }
.section { padding: 14px; border-bottom: 8px solid var(--bg); }
.section h2 { font-size: 14px; color: var(--green); margin: 0 0 10px; text-transform: uppercase; letter-spacing: .04em; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.row > .grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); } .small { font-size: 13px; }
.empty { text-align: center; color: var(--muted); padding: 40px 20px; }
input[type=text], input[type=email], select, textarea.field { font: inherit; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text); width: 100%; }
label { display: block; margin: 8px 0; } label > input, label > select { margin-top: 4px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; word-break: break-all; }
.qr { background: #fff; padding: 8px; border-radius: 8px; width: 160px; flex: none; }
.qr svg { width: 100%; height: auto; display: block; }
.big-id { font-size: 24px; font-weight: 700; letter-spacing: .06em; font-family: ui-monospace, Menlo, monospace; white-space: nowrap; }
#view { overflow-x: hidden; }
.row > .grow { overflow-wrap: anywhere; }
@media (max-width: 420px) { .qr { width: 130px; } .big-id { font-size: 20px; } }
.stat { display: inline-block; min-width: 120px; margin: 4px 12px 4px 0; }
.stat b { display: block; font-size: 22px; }
dialog { border: 0; border-radius: 12px; padding: 0; width: min(640px, 94vw); background: var(--panel); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { padding: 16px; } dialog menu { display: flex; justify-content: flex-end; gap: 8px; padding: 0; margin: 14px 0 0; }
#dlg-body h3 { margin-top: 0; } #dlg-body pre { white-space: pre-wrap; background: var(--bg); padding: 10px; border-radius: 8px; max-height: 50vh; overflow: auto; }
#toast { position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%); background: #323232; color: #fff;
  padding: 10px 16px; border-radius: 8px; z-index: 10; max-width: 90vw; }
.fab { position: sticky; bottom: 14px; float: right; margin: 14px; border-radius: 16px; font-size: 22px; padding: 12px 18px; }
/* login page */
body.login { display: grid; place-items: center; padding: 20px; }
.card { background: var(--panel); border-radius: 14px; padding: 28px; width: min(420px, 100%); text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.08); }
.card h1 { margin: 8px 0 0; } .card .sub { color: var(--muted); margin-top: 2px; }
.card form { text-align: left; } .card .btn { width: 100%; margin-top: 10px; }
.card .btn.ms { background: #2f2f2f; } .card .or { color: var(--muted); margin: 14px 0 4px; font-size: 13px; }
.err { color: var(--err); }
