:root {
  color-scheme: light;
  --bg: #d1d7db;
  --panel: #ffffff;
  --header: #f0f2f5;
  --hover: #f5f6f6;
  --active: #f0f2f5;
  --line: #e9edef;
  --text: #111b21;
  --muted: #667781;
  --accent: #00a884;
  --accent-deep: #008069;
  --wallpaper: #efeae2;
  --bubble-in: #ffffff;
  --bubble-out: #d9fdd3;
  --danger: #ea0038;
  --shadow: 0 1px 0.5px rgba(11, 20, 26, 0.13);
  --card: 0 18px 50px rgba(11, 20, 26, 0.16);
  --phone: #008069;
  font-family: "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body, #app { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { opacity: 0.55; cursor: default; }
img, video { max-width: 100%; }

.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; }
.login-card, .modal {
  width: min(440px, 100%);
  background: var(--panel);
  border-radius: 12px;
  padding: 28px 24px 22px;
  box-shadow: var(--card);
}
.brand { display: flex; gap: 12px; align-items: center; }
.logo {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff; font-weight: 800;
}
.mark { color: var(--muted); font-size: 12px; font-weight: 650; }
h1 { margin: 16px 0 6px; font-size: 28px; }
.login-card p, .hint { color: var(--muted); margin: 0 0 14px; line-height: 1.45; }
label { display: block; margin: 12px 0 6px; color: var(--muted); font-size: 13px; }
input, textarea {
  width: 100%; border: 0; background: var(--header); border-radius: 8px; padding: 12px 14px; outline: none; font-size: 16px;
}
.primary, .ghost, .danger {
  border: 0; border-radius: 24px; padding: 11px 16px; font-weight: 700;
}
.primary { background: var(--accent); color: #fff; width: 100%; margin-top: 16px; }
.ghost, .icon-btn {
  background: transparent; color: var(--muted); border: 0; border-radius: 50%;
  width: 40px; height: 40px; display: grid; place-items: center;
}
.icon-btn:hover, .ghost:hover { background: rgba(11, 20, 26, 0.06); color: var(--text); }
.linkish { background: none; border: 0; color: var(--accent-deep); padding: 0; font-weight: 700; }
.error { color: var(--danger); font-size: 14px; margin: 8px 0 0; }
.app { height: 100%; display: flex; background: var(--panel); }
.shell { flex: 1; min-height: 0; display: grid; grid-template-columns: 400px minmax(0, 1fr); }
.list, .thread { min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.list { background: var(--panel); border-right: 1px solid var(--line); }
.list-head, .thread-head {
  position: relative;
  background: var(--header); min-height: 60px; padding: 10px 12px;
  display: flex; align-items: center; gap: 8px;
}
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #111b21; color: #fff; padding: 12px 16px; border-radius: 8px; z-index: 60;
}
.list-head h1 { margin: 0; font-size: 21px; flex: 1; }
.thread-head { gap: 4px; }
.who {
  flex: 1; min-width: 0; background: none; border: 0; text-align: left; padding: 4px 6px;
  display: flex; align-items: center; gap: 10px; border-radius: 8px;
}
.who:hover { background: rgba(11, 20, 26, 0.05); }
.who-block { min-width: 0; }
.head-actions { margin-left: auto; display: flex; align-items: center; gap: 0; flex: 0 0 auto; }
.head-actions .icon-btn { width: 40px; height: 40px; }
.who strong, .who span, .ticket strong, .preview { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span, .preview, .when { color: var(--muted); }
.who span { font-size: 13px; }
.search-wrap { position: relative; display: flex; align-items: center; padding: 8px 12px 4px; }
.search-wrap .icon {
  position: absolute; left: 26px; top: 0; bottom: 0; margin: auto;
  width: 18px; height: 18px; color: var(--muted); pointer-events: none;
}
.search-wrap input { border-radius: 24px; padding: 10px 14px 10px 40px; background: #fff; }
.ticket.static { cursor: default; }
.ticket.static:hover { background: transparent; }
.update-form { display: flex; gap: 8px; padding: 8px 12px; align-items: center; }
.update-form input { flex: 1; }
.update-form .primary { width: auto; margin: 0; padding: 10px 14px; }
.section-label { padding: 14px 16px 4px; color: var(--accent-deep); font-size: 13px; font-weight: 700; }
.tabbar {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line); background: #fff;
  padding: 4px 0 calc(4px + env(safe-area-inset-bottom));
  flex: 0 0 auto;
}
.tabbar button {
  border: 0; background: transparent; color: #54656f;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 12px; font-weight: 600; padding: 6px 0 4px;
  width: auto; height: auto; border-radius: 0; min-height: 56px;
}
.tabbar button.is-on { color: var(--accent-deep); }
.tabbar .icon { width: 24px; height: 24px; }
.tab-icon { position: relative; display: grid; place-items: center; }
.tab-badge {
  position: absolute; top: -6px; right: -10px; min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 999px; background: var(--accent); color: #fff; font-size: 10px;
  display: grid; place-items: center;
}
.tickets { overflow: auto; flex: 1; }
.ticket {
  width: 100%; display: grid; grid-template-columns: 49px minmax(0, 1fr) auto; gap: 12px;
  align-items: center; padding: 10px 14px; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; text-align: left; min-height: 72px;
}
.ticket:hover { background: var(--hover); }
.ticket.is-active { background: var(--active); }
.avatar {
  width: 49px; height: 49px; border-radius: 50%; display: grid; place-items: center;
  color: #fff; font-weight: 700; background: var(--accent);
}
.avatar.sm { width: 40px; height: 40px; font-size: 16px; }
.dot { min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 12px; display: grid; place-items: center; }
.thread { background: var(--wallpaper); }
.messages {
  flex: 1; overflow: auto; padding: 16px 7% 8px;
  display: flex; flex-direction: column; gap: 3px;
  background-image: radial-gradient(rgba(84, 72, 56, 0.16) 0.7px, transparent 0.8px);
  background-size: 16px 16px;
}
.empty {
  margin: auto; text-align: center; color: var(--muted); background: var(--panel);
  border-radius: 12px; padding: 22px 26px; box-shadow: var(--shadow);
}
.day, .system {
  align-self: center; background: #fff; color: var(--muted); border-radius: 8px;
  padding: 6px 10px; font-size: 12.5px; box-shadow: var(--shadow); margin: 8px 0;
  max-width: 86%; text-align: center;
}
.bubble {
  max-width: min(680px, 82%); padding: 6px 8px 4px; border-radius: 8px;
  box-shadow: var(--shadow); line-height: 1.35; position: relative;
}
.bubble.in { background: var(--bubble-in); align-self: flex-start; border-top-left-radius: 0; }
.bubble.out { background: var(--bubble-out); align-self: flex-end; border-top-right-radius: 0; }
.bubble .name { font-size: 12.5px; font-weight: 700; }
.bubble .time { color: var(--muted); font-size: 11px; text-align: right; margin-top: 2px; display: flex; justify-content: flex-end; gap: 8px; }
.bubble .text { white-space: pre-wrap; word-break: break-word; }
.shot { display: block; width: min(280px, 68vw); max-height: 360px; object-fit: cover; border-radius: 6px; margin-top: 2px; cursor: zoom-in; background: #111; }
.file-link { display: inline-flex; margin-top: 6px; color: #027eb5; font-weight: 650; background: none; border: 0; padding: 0; }
.doc-card {
  display: flex; align-items: center; gap: 10px; min-width: 230px; max-width: 280px;
  margin-top: 4px; padding: 8px; border-radius: 8px; text-decoration: none; color: inherit;
  background: color-mix(in srgb, var(--text) 6%, transparent);
}
.doc-ico {
  width: 46px; height: 52px; border-radius: 6px; display: grid; place-items: center;
  color: #fff; font-size: 11px; font-weight: 800; flex: 0 0 auto;
}
.doc-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.doc-copy strong { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-copy small { color: var(--muted); font-size: 12px; }
.wa-voice { display: flex; align-items: center; gap: 8px; min-width: 210px; margin-top: 4px; }
.wa-voice button { width: 34px; height: 34px; border: 0; border-radius: 50%; background: var(--accent); color: #fff; }
.composer {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--header);
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
}
.pill {
  flex: 1; display: flex; align-items: flex-end; gap: 2px; background: var(--panel);
  border-radius: 24px; padding: 4px 4px 4px 14px; box-shadow: var(--shadow); min-height: 48px;
}
.mic-fab {
  width: 48px; height: 48px; border: 0; border-radius: 50%; flex: 0 0 auto;
  background: var(--accent); color: #fff; display: grid; place-items: center;
}
.mic-fab .icon { width: 24px; height: 24px; }
.mic-fab.rec { background: var(--danger); }
.pill textarea {
  flex: 1; min-width: 0; width: auto; background: transparent; border-radius: 0;
  padding: 10px 4px; resize: none; max-height: 120px; line-height: 1.35; min-height: 22px;
}
.pill-icons { display: flex; align-items: center; flex: 0 0 auto; padding-bottom: 2px; }
.pill-icons .icon-btn { width: 36px; height: 36px; color: #54656f; }
.pill-icons .send-in { color: var(--accent); }
.profile-pane { flex: 1; min-height: 0; overflow: auto; background: #fff; }
.profile-hero { display: flex; flex-direction: column; align-items: center; padding: 28px 16px 18px; background: var(--header); }
.avatar.xl { width: 128px; height: 128px; font-size: 52px; }
.profile-name { font-size: 24px; margin-top: 12px; }
.profile-sub { color: var(--muted); margin-top: 2px; }
.profile-label {
  color: var(--accent-deep); font-size: 14px; font-weight: 700;
  padding: 18px 16px 8px; background: #fff;
}
.media-tabs { display: flex; background: #fff; border-bottom: 1px solid var(--line); }
.media-tabs button {
  flex: 1; border: 0; background: #fff; padding: 12px 8px; color: var(--muted);
  border-bottom: 2px solid transparent; border-radius: 0; width: auto; height: auto;
}
.media-tabs button.is-on { color: var(--accent-deep); border-bottom-color: var(--accent); font-weight: 700; }
.profile-tab-body { background: #fff; min-height: 88px; }
.media-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.media-grid img, .media-grid video { width: 100%; height: 112px; object-fit: cover; border-radius: 0; margin: 0; cursor: pointer; }
.doc-row, .option-row {
  display: flex; width: 100%; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; background: #fff; border: 0; border-top: 1px solid var(--line);
  text-align: left; color: var(--text); text-decoration: none; border-radius: 0; height: auto;
}
.option-row span { min-width: 0; }
.option-row strong, .option-row small { display: block; }
.option-row small { color: var(--muted); font-size: 13px; font-weight: 400; margin-top: 2px; }
.option-row em { font-style: normal; color: var(--muted); }
.option-row.static { cursor: default; }
.chev { color: var(--muted); display: grid; transform: scaleX(-1); }
.member-list { background: #fff; }
.storage-total { padding: 0 16px; }
.profile-pane .row-actions { padding: 8px 16px 24px; }
.profile-pane .hint { padding: 8px 16px; }
.icon { width: 22px; height: 22px; display: block; fill: currentColor; }
.menu-back { position: fixed; inset: 0; z-index: 4; border: 0; background: transparent; width: 100%; height: 100%; border-radius: 0; }
.menu {
  position: absolute; z-index: 6; right: 8px; top: 48px; background: var(--panel); color: var(--text); border-radius: 8px;
  box-shadow: var(--card); min-width: 220px; padding: 6px; display: flex; flex-direction: column;
}
.settings-body { flex: 1; min-height: 0; overflow: auto; background: var(--header); }
.settings-stack, .settings-form { display: flex; flex-direction: column; gap: 8px; }
.settings-hero {
  background: var(--panel); display: flex; flex-direction: column; align-items: center;
  padding: 28px 16px 22px; text-align: center;
}
.photo-wrap { position: relative; width: fit-content; }
.cam {
  position: absolute; right: 2px; bottom: 4px; width: 42px; height: 42px; border-radius: 50%;
  background: var(--accent); color: #fff; border: 3px solid var(--panel);
  display: grid; place-items: center; padding: 0;
}
.cam .icon { width: 22px; height: 22px; }
img.avatar.photo { object-fit: cover; }
.hero-name {
  border: 0; background: transparent; height: auto; margin-top: 14px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 0;
}
.hero-name strong { font-size: 22px; }
.hero-name span { color: var(--muted); }
.set-card { background: var(--panel); }
.set-card label { margin: 0; padding: 14px 16px 0; color: var(--accent-deep); font-weight: 700; }
.set-card input, .set-card textarea { width: calc(100% - 32px); margin: 6px 16px 12px; }
.set-card textarea { min-height: 72px; resize: vertical; border: 0; border-radius: 8px; background: var(--header); padding: 10px 12px; }
.sheet-page { position: fixed; inset: 0; z-index: 35; display: flex; flex-direction: column; background: var(--header); }
.flow-badge.community { position: relative; }
.flow-cam { position: absolute; right: -4px; bottom: -4px; width: 36px; height: 36px; border-radius: 50%; background: #00a884; color: #fff; display: grid; place-items: center; border: 3px solid #fff; }
.flow-cam .icon { width: 18px; height: 18px; }
.set-static { padding: 2px 16px 16px; color: var(--text); }
.set-label { padding: 14px 16px 6px; color: var(--accent-deep); font-size: 14px; font-weight: 700; }
.set-row {
  width: 100%; display: flex; align-items: center; gap: 16px; padding: 12px 16px;
  border: 0; border-bottom: 1px solid var(--line); background: var(--panel);
  text-align: left; height: auto; border-radius: 0;
}
.set-row.static { cursor: default; }
.set-ico {
  width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--accent) 16%, var(--panel)); color: var(--accent-deep); flex: 0 0 auto;
}
.set-ico .icon { width: 22px; height: 22px; }
.set-copy { flex: 1; min-width: 0; }
.set-row strong { display: block; font-size: 16px; font-weight: 500; }
.set-row small, .set-note span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.radio-row {
  width: 100%; display: flex; align-items: center; gap: 14px; padding: 13px 16px;
  border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; height: auto; border-radius: 0;
}
.radio { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #8696a0; flex: 0 0 auto; }
.radio.on { border-color: var(--accent); background: radial-gradient(circle, var(--accent) 0 6px, transparent 7px); }
.switch { width: 46px; height: 26px; border-radius: 13px; background: #d1d7db; position: relative; flex: 0 0 auto; }
.switch.on { background: var(--accent); }
.switch i { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; display: block; }
.switch.on i { left: 23px; }
.settings-form .primary { margin: 8px 16px 16px; border-radius: 24px; }
.settings-logout { width: auto; margin: 16px; }
.set-note { padding: 16px; }
.help-copy { padding: 8px 16px 24px; color: var(--text); line-height: 1.45; }
.help-copy p { margin: 0 0 12px; }
html[data-theme="dark"] {
  --bg: #0b141a; --panel: #111b21; --header: #202c33; --hover: #2a3942; --active: #2a3942;
  --line: #222d34; --text: #e9edef; --muted: #8696a0; --wallpaper: #0b141a;
  --bubble-in: #202c33; --bubble-out: #005c4b; --phone: #202c33;
}
html[data-wallpaper="plain"] .messages { background-image: none; background-color: #efeae2; }
html[data-wallpaper="dark"] .messages { background-image: none; background-color: #0b141a; }
html[data-font="small"] .messages, html[data-font="small"] .bubble { font-size: 14px; }
html[data-font="large"] .messages, html[data-font="large"] .bubble { font-size: 18px; }
.linkish.is-star { color: #e0a100; }
.menu button { width: 100%; background: none; border: 0; text-align: left; padding: 12px 16px; border-radius: 0; font-size: 16px; color: var(--text); display: flex; align-items: center; gap: 18px; }
.menu .icon { width: 22px; height: 22px; color: #54656f; }
.menu button:hover { background: var(--hover); }
.modal-back { position: fixed; inset: 0; background: rgba(11, 20, 26, 0.45); display: grid; place-items: center; z-index: 30; padding: 16px; }
.modal { max-height: min(640px, 100%); display: flex; flex-direction: column; padding: 16px; }
.modal h2 { margin: 0 0 10px; }
.modal .results { overflow: auto; display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.person, .pick {
  display: flex; gap: 10px; align-items: center; width: 100%; text-align: left;
  border: 0; background: transparent; padding: 8px; border-radius: 8px;
}
.person:hover, .pick:hover { background: var(--hover); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.chip { background: #e7fce3; color: var(--accent-deep); border-radius: 999px; padding: 4px 10px; border: 0; }
.row-actions { display: flex; gap: 8px; margin-top: 12px; }
.row-actions .primary, .row-actions .danger { width: auto; margin: 0; }
.danger { background: var(--danger); color: #fff; }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 40; display: grid; place-items: center; }
.lightbox img { max-width: min(1000px, 94vw); max-height: 90vh; }
.call-overlay {
  position: fixed; inset: 0; z-index: 80; background: #0b141a; color: #fff;
  display: flex; flex-direction: column;
}
.stage { position: relative; flex: 1; min-height: 0; background: #000; }
.stage video.remote, .stage video.local-full { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }
.call-overlay.is-screen video.remote { object-fit: contain; }
.stage video.local {
  position: absolute; right: 16px; bottom: 16px; width: 112px; height: 168px; object-fit: cover;
  border-radius: 12px; border: 2px solid rgba(255,255,255,.35); z-index: 2; background: #111;
}
.hero {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  background: linear-gradient(180deg, rgba(11,20,26,.2), rgba(11,20,26,.78));
}
.pulse { width: 132px; height: 132px; display: grid; place-items: center; position: relative; }
.pulse span { position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(37,211,102,.45); animation: pulse 1.8s ease-out infinite; }
.pulse span:nth-child(2) { animation-delay: .6s; }
@keyframes pulse { from { transform: scale(.72); opacity: .8; } to { transform: scale(1.35); opacity: 0; } }
.hero .avatar { width: 96px; height: 96px; font-size: 40px; background: #25d366; color: #053b24; z-index: 1; }
.hero h2 { margin: 8px 0 0; font-size: 28px; font-weight: 600; }
.hero p { margin: 0; color: rgba(255,255,255,.75); }
.controls { display: flex; justify-content: center; gap: 22px; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.round { width: 62px; height: 62px; border-radius: 50%; border: 0; color: #fff; display: grid; place-items: center; background: rgba(255,255,255,.16); }
.round.accept { background: #25d366; }
.round.decline { background: #f15c6d; }
.round.on { background: var(--accent); }
.rec { color: var(--danger) !important; }
@media (max-width: 860px) {
  .shell { display: block; position: relative; }
  .list, .thread { position: absolute; inset: 0; }
  .app.is-chat .list { display: none; }
  .app:not(.is-chat) .thread { display: none; }
  .list-head, .thread-head { background: var(--phone); color: #fff; padding-top: calc(10px + env(safe-area-inset-top)); }
  .list-head .icon-btn, .thread-head .icon-btn, .who, .who span, .who strong { color: #fff; }
  .who:hover { background: rgba(255, 255, 255, 0.08); }
  .back { display: grid; }
}
@media (min-width: 861px) {
  .back { display: none; }
  .thread.is-profile .back { display: grid; }
}
.notice {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 60;
  width: min(420px, calc(100% - 24px)); background: #fff; color: var(--text);
  border: 0; border-radius: 12px; box-shadow: var(--card);
  display: flex; gap: 10px; align-items: center; padding: 10px 12px; text-align: left;
}
.notice-copy { display: flex; flex-direction: column; min-width: 0; }
.notice-copy strong, .flow-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flow-hero { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 28px 16px 12px; background: #fff; }
.flow-badge { width: 112px; height: 112px; border-radius: 28px; background: #dfe5e7; color: #54656f; display: grid; place-items: center; position: relative; }
.flow-badge .icon { width: 64px; height: 64px; }
.flow-badge .flow-cam { position: absolute; right: 0; bottom: 0; width: 36px; height: 36px; border-radius: 50%; background: #00a884; color: #fff; display: grid; place-items: center; border: 3px solid #fff; }
.flow-badge .flow-cam .icon { width: 18px; height: 18px; }
.flow-ico { width: 46px; height: 46px; border-radius: 50%; background: #00a884; color: #fff; display: grid; place-items: center; flex: 0 0 auto; }
.flow-ico .icon { width: 24px; height: 24px; }
.flow-person { padding: 12px 16px; border-radius: 0; background: #fff; border-bottom: 1px solid var(--line); }
.flow-copy { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #8696a0; flex: 0 0 auto; }
.check.on { background: #00a884; border-color: #00a884; box-shadow: inset 0 0 0 4px #fff; }
.flow-chips { padding: 8px 12px 0; }
.flow-go { width: calc(100% - 32px); margin: 16px; }
