

html.client,
html.client body {
  height: 100%;
  background: #f2f2f7;
}

@media (prefers-color-scheme: dark) {
  html.client, html.client body { background: #000; }
}

html:not(.client) .status,
html:not(.client) .contact { display: none; }

html.client .bar,
html.client .trace,
html.client .note { display: none; }

html.client .note.note--demo {
  display: block;
  color: var(--muted);
  padding: 0.5rem 0.75rem 0.75rem;
  line-height: 1.4;
}

html.client .wrap {
  display: block;
  max-width: none;
  margin: 0;
  padding: 0;
  height: 100dvh;
}

html.client .phone {
  --recv: #e9e9eb;
  --recv-ink: #000;
  --sent: #34c759;
  --sent-ink: #fff;
  --chrome: #f6f6f6;
  --chrome-ink: #000;
  --hair: rgba(0, 0, 0, 0.18);

  --muted: #6e6e73;

  display: flex;
  flex-direction: column;
  width: min(390px, 100vw);
  height: min(844px, 100dvh);

  max-height: 100dvh;
  min-height: 0;
  margin: max(0px, calc((100dvh - 844px) / 2)) auto;
  background: #fff;
  border-radius: 0;
  overflow: hidden;
  border: 0;
}

@media (min-width: 440px) and (min-height: 900px) {
  html.client .phone {
    border: 10px solid #1c1c1e;
    border-radius: 44px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  }
}

@media (prefers-color-scheme: dark) {
  html.client .phone {
    --recv: #262628;
    --recv-ink: #fff;
    --chrome: #1c1c1e;
    --chrome-ink: #fff;
    --hair: rgba(255, 255, 255, 0.16);
    background: #000;
  }
}

html.client .status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1.5rem 0.2rem;
  background: var(--chrome);
  color: var(--chrome-ink);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

html.client .status-r { display: flex; align-items: center; gap: 4px; }

html.client .sig,
html.client .batt {
  display: inline-block;
  background: currentColor;
  opacity: 0.85;
}
html.client .sig  { width: 16px; height: 10px; clip-path: polygon(0 70%,20% 70%,20% 100%,0 100%,25% 45%,45% 45%,45% 100%,25% 100%,50% 22%,70% 22%,70% 100%,50% 100%,75% 0,95% 0,95% 100%,75% 100%); }
html.client .batt { width: 22px; height: 11px; border-radius: 3px; }

html.client .contact {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 1rem 0.7rem;
  background: var(--chrome);
  color: var(--chrome-ink);
  border-bottom: 1px solid var(--hair);
}

html.client .avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: #8e8e93;
  color: #fff;
  display: grid; place-items: center;
  font-size: 0.72rem; font-weight: 600;
  text-transform: uppercase;
  flex: none;
}

html.client .who {
  font-size: 0.95rem;
  font-weight: 600;

  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

html.client .restart {
  flex: none;
  background: none; border: 0;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1;
  padding: 0.35rem;
  cursor: pointer;
  border-radius: 8px;

  min-width: 24px; min-height: 24px;
}
html.client .restart:hover { color: var(--chrome-ink); }

html.client .thread {
  flex: 1;
  gap: 2px;
  padding: 0.9rem 0.85rem;
  background: transparent;
  overflow-y: auto;
}

html.client .msg {
  max-width: 76%;
  padding: 0.5rem 0.78rem;
  border-radius: 19px;
  font-size: 1.0rem;
  line-height: 1.35;
  border: 0;
}

html.client .msg.them {
  background: var(--recv);
  color: var(--recv-ink);
  border-bottom-left-radius: 19px;
  margin-bottom: 0.35rem;
}

html.client .msg.us {
  background: var(--sent);
  color: var(--sent-ink);
  border-bottom-right-radius: 19px;
  margin-bottom: 0.35rem;
}

html.client .msg.them + .msg.them,
html.client .msg.us + .msg.us { margin-top: -0.25rem; }

html.client .msg a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

html.client .sys {
  align-self: center;
  color: var(--muted);
  font-size: 0.74rem;
  padding: 0.5rem 0;
  text-align: center;
}

html.client .sys.sys--owner,
.sys.sys--owner {
  align-self: stretch;
  text-align: left;
  margin: 0.25rem 0.75rem;
  padding: 0.6rem 0.75rem;
  border: 1px dashed var(--hair);
  border-radius: 12px;
  line-height: 1.4;
}

.sys--owner .sys__pic { display: block; width: 96px; height: 96px; object-fit: cover; border-radius: 8px; margin-top: 8px; }

html.client .composer {
  display: flex;

  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem calc(0.6rem + env(safe-area-inset-bottom));
  background: var(--chrome);
  border-top: 1px solid var(--hair);
}

html.client .composer .composer__field {

  resize: none;
  overflow-y: auto;
  max-height: 8.5em;
  line-height: 1.35;
  font-family: inherit;
  flex: 1;
  min-width: 0;
  background: transparent;
  color: var(--chrome-ink);
  border: 1px solid var(--hair);
  border-radius: 18px;
  padding: 0.5rem 0.9rem;

  font-size: 16px;
}

html.client .composer .composer__field:focus {
  outline: none;
  border-color: var(--muted);
}

html.client .composer .composer__send {
  flex: none;
  width: 30px; height: 30px;
  padding: 0;
  border: 0; border-radius: 50%;
  background: var(--sent);
  color: #fff;
  font-size: 0;
  cursor: pointer;
  position: relative;
}
html.client .composer .composer__send::after {
  content: "↑";
  font-size: 1rem;
  font-weight: 700;
  position: absolute; inset: 0;
  display: grid; place-items: center;
}
html.client .composer .composer__send:disabled { opacity: 0.35; cursor: default; }

html.client .composer .composer__photo[hidden] { display: none !important; }
html.client .composer .composer__photo {
  flex: none;
  width: 30px; height: 30px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--muted);
  cursor: pointer;
}
html.client .composer .composer__photo::before {
  content: "";
  width: 22px; height: 22px;
  background: currentColor;
  -webkit-mask: url("/assets/img/icons/camera.svg") center / contain no-repeat;
          mask: url("/assets/img/icons/camera.svg") center / contain no-repeat;
}
html.client .composer .composer__photo:focus-within { outline: 2px solid var(--muted); outline-offset: 2px; }

html.client .msg.us.msg--photo { padding: 4px; background: var(--sent); }
.msg--photo img { display: block; max-width: 180px; max-height: 220px; border-radius: 14px; object-fit: cover; }

html.client .status-l {
  color: inherit;
  text-decoration: none;
}
html.client .status-l:hover { text-decoration: underline; }

@media (prefers-reduced-motion: no-preference) {
  html.client .msg { animation: pop 140ms ease-out; }
  @keyframes pop {
    from { transform: translateY(3px); opacity: 0; }
    to   { transform: none; opacity: 1; }
  }
}
