:root {
  --brand: #0f766e;
  --brand-dark: #115e59;
  --bg: #f4f6f5;
  --card: #fff;
  --text: #1f2933;
  --muted: #5b6770;
  --mine: #d9f2ec;
  --theirs: #fff;
  --danger: #b42318;
  font-size: 18px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", "Noto Sans", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.45;
  display: flex; flex-direction: column;
}
.banner { background: #fff4d6; color: #6b4e00; font-size: .8rem; padding: .35rem .8rem; text-align: center; }
.view { flex: 1; display: flex; flex-direction: column; padding: .8rem; max-width: 720px; width: 100%; margin: 0 auto; min-height: 0; }
.view.center { align-items: center; justify-content: center; }
.brand { color: var(--brand); font-size: 1.6rem; margin: .2rem 0; font-weight: 700; }
.brand small { font-size: .9rem; color: var(--muted); font-weight: 400; }
.grow { flex: 1; min-width: 0; }
.bar { display: flex; align-items: center; gap: .5rem; padding-bottom: .5rem; border-bottom: 1px solid #dde3e1; margin-bottom: .6rem; }
.bar h2 { margin: 0; font-size: 1.3rem; }
.title > div:first-child { font-weight: 700; font-size: 1.15rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sub { color: var(--muted); font-size: .85rem; }
.big { font-size: 1.25rem; font-weight: 700; }
.hint { color: var(--muted); font-size: .9rem; margin: .4rem 0; }
.error { color: var(--danger); min-height: 1.2em; }
.error a { color: var(--brand); font-weight: 700; }

label { display: block; margin: .7rem 0; }
label > span { display: block; margin-bottom: .25rem; font-weight: 600; }
label.check { display: flex; gap: .6rem; align-items: flex-start; }
label.check > span { font-weight: 400; margin: 0; }
input[type=checkbox] { width: 1.4rem; height: 1.4rem; flex: none; margin-top: .1rem; accent-color: var(--brand); }
input, textarea {
  width: 100%; font: inherit; padding: .65rem .75rem; border: 1px solid #b9c4c0; border-radius: .6rem; background: #fff; color: inherit;
}
textarea { resize: none; max-height: 8rem; }
button {
  font: inherit; min-height: 48px; padding: .5rem 1rem; border-radius: .6rem; border: 1px solid #b9c4c0;
  background: #fff; color: var(--text); cursor: pointer;
}
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
button.primary:active { background: var(--brand-dark); }
button.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
button.accept { background: #1a7f37; border-color: #1a7f37; color: #fff; font-weight: 700; }
button.icon { min-width: 48px; padding: .3rem .6rem; font-size: 1.3rem; background: transparent; border-color: transparent; }
button.link { background: none; border: none; color: var(--brand); text-decoration: underline; align-self: flex-start; }
#r-submit { width: 100%; margin-top: .4rem; }
.row { display: flex; gap: .5rem; align-items: center; }
.row input { flex: 1; }
.notice { background: #fff; border: 1px solid #dde3e1; border-radius: .6rem; padding: .5rem .8rem; margin: .8rem 0; font-size: .88rem; }
.notice summary { font-weight: 700; cursor: pointer; }
.notice p { margin: .4rem 0; }
.card { background: var(--card); border-radius: .8rem; padding: .8rem; margin-bottom: .7rem; box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.card.row { flex-wrap: wrap; }
.conn { font-size: .8rem; color: var(--danger); }
.conn.ok { color: #1a7f37; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { margin-bottom: .5rem; }
.list li > button { width: 100%; text-align: left; background: var(--card); border: none; box-shadow: 0 1px 2px rgba(0,0,0,.06); padding: .7rem .9rem; display: flex; align-items: center; gap: .6rem; }
.list .name { font-weight: 700; font-size: 1.1rem; }
.list .badge { margin-left: auto; background: var(--danger); color: #fff; border-radius: 1rem; min-width: 1.6rem; padding: 0 .45rem; text-align: center; font-size: .85rem; }

.chat { padding-bottom: 0; }
.msgs { list-style: none; margin: 0; padding: .2rem 0 .6rem; flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: .45rem; min-height: 0; }
.msg { max-width: 82%; padding: .5rem .75rem; border-radius: .9rem; background: var(--theirs); box-shadow: 0 1px 2px rgba(0,0,0,.07); align-self: flex-start; cursor: pointer; }
.msg.mine { background: var(--mine); align-self: flex-end; }
.msg .text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 1.05rem; }
.msg.removed .text { color: var(--muted); font-style: italic; }
.msg .fwd { font-size: .78rem; color: var(--muted); }
.msg .meta { font-size: .75rem; color: var(--muted); text-align: right; margin-top: .15rem; }
.msg .st { margin-left: .35rem; }
.msg .st-failed { color: var(--danger); font-weight: 700; }
.msg .acts { display: none; gap: .4rem; margin-top: .35rem; }
.msg.open .acts { display: flex; }
.msg .acts button { min-height: 38px; padding: .2rem .7rem; font-size: .85rem; }
.composer { display: flex; gap: .5rem; padding: .5rem 0 calc(.6rem + env(safe-area-inset-bottom)); border-top: 1px solid #dde3e1; align-items: flex-end; }

dialog { border: none; border-radius: .8rem; padding: 1rem; width: min(92vw, 420px); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h3 { margin-top: 0; }

.call { position: fixed; inset: 0; background: #111; color: #fff; z-index: 10; display: flex; flex-direction: column; }
.call video { background: #000; }
#v-remote { flex: 1; width: 100%; min-height: 0; object-fit: contain; }
#v-local { position: absolute; right: .8rem; top: .8rem; width: 28vw; max-width: 180px; border-radius: .6rem; border: 2px solid #fff; }
.call.audio #v-local, .call.audio #v-remote { visibility: hidden; }
.call-info { position: absolute; left: 0; right: 0; top: 30%; text-align: center; text-shadow: 0 1px 3px #000; pointer-events: none; }
.call.connected:not(.audio) .call-info { top: auto; bottom: 7.5rem; }
.call-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: .8rem; padding: 1rem 1rem calc(1.2rem + env(safe-area-inset-bottom)); }
.call-actions button { min-width: 6.5rem; min-height: 56px; }

.toast { position: fixed; left: 50%; bottom: 5.5rem; transform: translateX(-50%); background: rgba(20,20,20,.92); color: #fff; padding: .65rem 1rem; border-radius: .7rem; max-width: 90vw; z-index: 20; text-align: center; }
