* { box-sizing: border-box; }
* {
  scrollbar-width: thin;
  scrollbar-color: #aeb8c7 transparent;
}
*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  min-height: 40px;
  border-radius: 999px;
  background: #aeb8c7;
}
*::-webkit-scrollbar-button {
  width: 0;
  height: 0;
  display: none;
}
:root {
  --space-xs: .25rem;
  --space-sm: .5rem;
  --space-md: .75rem;
  --space-lg: 1rem;
  --text-xs: .75rem;
  --text-sm: .875rem;
  --text-md: 1rem;
  --text-lg: 1.25rem;
  --text-xl: 1.75rem;
  --chat-head-height: 54px;
  --notice-height: 28px;
  --composer-height: 58px;
  --messages-height: calc(var(--app-height, 100dvh) - var(--chat-head-height) - var(--notice-height) - var(--composer-height));
}
html, body {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: none;
  touch-action: auto;
}
body {
  margin: 0;
  position: relative;
  min-height: var(--app-height, 100dvh);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  font-size: var(--text-md);
  background: #ededed;
  color: #111827;
}
html.contained-mobile-root,
html.contained-mobile-root body {
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100dvh);
  overflow: hidden;
}
button, input {
  font: inherit;
}
button {
  border: 0;
  cursor: pointer;
}
button:disabled {
  opacity: .55;
  cursor: not-allowed;
}
.hidden { display: none !important; }
.app {
  width: 100%;
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100dvh);
  overflow: hidden;
  background: #ededed;
}
body.contained-mobile {
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100dvh);
  position: fixed;
  inset: 0;
  overflow: hidden;
}
body.contained-mobile .app {
  position: fixed;
  inset: 0;
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100dvh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
body.contained-mobile .chat {
  position: fixed;
  inset: 0;
  width: 100%;
  height: var(--app-height, 100dvh);
  min-height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100dvh);
  display: block;
  overflow: hidden;
}
body.contained-mobile .chat-head {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 8;
  min-height: var(--chat-head-height);
}
body.contained-mobile .messages {
  position: fixed;
  top: var(--chat-head-height);
  left: 0;
  right: 0;
  bottom: calc(var(--composer-height) + var(--notice-height));
  height: var(--messages-height);
  min-height: var(--messages-height);
  max-height: var(--messages-height);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
body.contained-mobile .notice {
  position: fixed;
  left: 0;
  right: 0;
  bottom: var(--composer-height);
  z-index: 8;
  min-height: var(--notice-height);
}
body.contained-mobile .composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9;
  min-height: var(--composer-height);
}
.boot,
.login {
  min-height: var(--app-height, 100dvh);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 28px 12vh;
}
.boot {
  align-items: center;
  color: #64748b;
  font-size: var(--text-md);
}
.login h1 {
  margin: 0 0 2.125rem;
  text-align: center;
  font-size: var(--text-xl);
  font-weight: 600;
}
.login input {
  height: 48px;
  margin-bottom: .875rem;
  padding: 0 .875rem;
  border: 0;
  border-bottom: 1px solid #d4d4d8;
  border-radius: 0;
  background: transparent;
  font-size: var(--text-md);
}
.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin: -.125rem 0 1rem;
  color: #64748b;
  font-size: var(--text-sm);
}
.login-options label {
  display: inline-flex;
  align-items: center;
  gap: .375rem;
  min-width: 0;
  white-space: nowrap;
}
.login-options input {
  width: 16px;
  height: 16px;
  margin: 0;
  padding: 0;
  accent-color: #07c160;
}
.login button,
.sheet-panel > button {
  height: 46px;
  border-radius: 6px;
  background: #07c160;
  color: #fff;
  font-weight: 600;
}
#loginMsg,
#forcePasswordMsg,
#profileMsg,
.notice {
  min-height: 22px;
  margin: .625rem 0 0;
  color: #dc2626;
  font-size: var(--text-sm);
}
.chat {
  position: relative;
  height: var(--app-height, 100dvh);
  max-height: var(--app-height, 100dvh);
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: #ededed;
  overflow: hidden;
}
.chat-head {
  flex: 0 0 auto;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  padding: var(--space-sm) .625rem;
  background: #f7f7f7;
  border-bottom: 1px solid #d7d7d7;
  user-select: none;
  -webkit-user-select: none;
}
.head-avatar {
  width: 30px;
  height: 30px;
  border-radius: 5px;
  object-fit: cover;
  background: #dbe4ef;
}
.room-title-wrap {
  position: absolute;
  left: 50%;
  max-width: 42%;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 1px;
  text-align: center;
}
.room-title {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
}
#memberCountText {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #7b8493;
  font-size: .6875rem;
  line-height: 1.1;
}
.head-btn {
  position: relative;
  z-index: 1;
  width: auto;
  min-width: 42px;
  height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  background: #eef2f7;
  font-size: .8125rem;
}
.profile-btn {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: .375rem;
  max-width: 44%;
  height: 38px;
  padding: 4px 2px 4px 6px;
  background: transparent;
  color: #111827;
}
.profile-btn span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-gear {
  flex: 0 0 auto;
  font-size: 1.1875rem;
}
.messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: var(--space-md) .625rem var(--space-lg);
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}
.msg {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  user-select: none;
  -webkit-user-select: none;
}
.msg.me {
  flex-direction: row-reverse;
  justify-content: flex-start;
}
.msg.other {
  justify-content: flex-start;
}
.msg.system {
  justify-content: center;
}
.avatar {
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 5px;
  object-fit: cover;
  background: #dbe4ef;
}
.msg-body {
  max-width: calc(100vw - 92px);
}
.msg.me .msg-body {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.msg.other .msg-body {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.meta {
  margin-bottom: .1875rem;
  color: #7b8493;
  font-size: var(--text-xs);
  user-select: none;
  -webkit-user-select: none;
}
.msg.me .meta {
  text-align: right;
}
.bubble {
  position: relative;
  display: inline-block;
  max-width: 100%;
  min-width: 54px;
  padding: .5625rem .6875rem 1.125rem .6875rem;
  border-radius: 6px;
  background: #fff;
  border: 1px solid #ddd;
  line-height: 1.45;
  word-break: break-word;
  user-select: none;
  -webkit-user-select: none;
}
.bubble.text-bubble {
  padding-right: 3rem;
}
.bubble-content {
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}
.bubble-content * {
  user-select: text;
  -webkit-user-select: text;
  -webkit-touch-callout: default;
}
.bubble.image-bubble {
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-touch-callout: none;
}
.bubble a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.msg.other .bubble a {
  color: #1769e0;
}
.msg.me .bubble {
  background: #95ec69;
  border-color: #86d95f;
}
.msg.system .bubble {
  padding: .3125rem .625rem;
  border: 0;
  border-radius: 12px;
  background: #d5dbe3;
  color: #64748b;
  font-size: .8125rem;
}
.msg.system .msg-clock {
  display: none;
}
.msg-clock {
  position: absolute;
  right: 7px;
  bottom: 4px;
  color: #8a94a6;
  font-size: .625rem;
  font-weight: 400;
  line-height: 1;
  white-space: nowrap;
  opacity: .9;
  user-select: none;
  -webkit-user-select: none;
}
.msg.me .msg-clock {
  color: #5f8f4e;
}
.msg-status {
  margin-top: .25rem;
  padding: 0;
  background: transparent;
  color: #8a94a6;
  font-size: .6875rem;
  line-height: 1.2;
  text-align: right;
}
.msg-status.status-failed {
  color: #dc2626;
  cursor: pointer;
}
.msg-status.status-sending {
  cursor: default;
}
.msg-status.status-sent {
  color: #8a94a6;
}
.bubble img {
  display: block;
  max-width: 132px;
  max-height: 88px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 5px;
  background: #eef2f7;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.bubble img.loading {
  display: none;
}
.image-loading,
.image-error {
  display: inline-block;
  min-width: 88px;
  min-height: 60px;
  line-height: 60px;
  color: #64748b;
  font-size: .8125rem;
}
.image-error {
  display: inline-block;
  color: #dc2626;
}
.notice {
  flex: 0 0 auto;
  margin: 0;
  padding: .1875rem .75rem;
  background: #fff7ed;
}
.composer {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: var(--space-sm);
  align-items: center;
  padding: var(--space-sm) .625rem calc(var(--space-sm) + env(safe-area-inset-bottom));
  background: #f7f7f7;
  border-top: 1px solid #d7d7d7;
}
body.keyboard-open .composer {
  padding-bottom: var(--space-sm);
}
.composer input {
  height: 40px;
  min-width: 0;
  padding: 0 .75rem;
  border: 1px solid #d6d6d6;
  border-radius: 5px;
  background: #fff;
  font-size: var(--text-md);
  -webkit-user-select: text;
  user-select: text;
  touch-action: auto;
}
.composer button {
  height: 40px;
  border-radius: 5px;
  background: #07c160;
  color: #fff;
  font-weight: 600;
}
body.conservative-mobile .app,
body.conservative-mobile .chat {
  height: auto;
  min-height: 100svh;
  max-height: none;
  overflow: visible;
}
body.conservative-mobile {
  min-height: 100svh;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}
body.conservative-mobile .chat {
  display: flex;
  flex-direction: column;
  overflow: visible;
}
body.conservative-mobile .messages {
  flex: 1 1 auto;
  height: auto;
  min-height: 240px;
  max-height: none;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}
body.conservative-mobile .composer {
  position: sticky;
  bottom: 0;
  z-index: 3;
}
.sheet {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
  background: rgba(0, 0, 0, .35);
  overscroll-behavior: contain;
}
.sheet-panel {
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 18px calc(18px + env(safe-area-inset-bottom));
  border-radius: 16px 16px 0 0;
  background: #fff;
}
.sheet-panel.compact {
  max-width: 340px;
  margin: auto 18px;
  padding: 22px 18px 24px;
  place-self: center;
  border-radius: 12px;
}
.sheet-panel.compact h2 {
  margin-bottom: 16px;
}
.sheet-panel.compact p {
  margin: 0 0 18px;
  line-height: 1.45;
}
.sheet-panel.compact input {
  height: 44px;
  margin: 0 0 12px;
}
.sheet-panel.compact button {
  min-width: 104px;
  height: 44px;
  margin-top: 8px;
  border-radius: 7px;
}
#forcePasswordMsg {
  margin-top: 12px;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.sheet h2 {
  margin: 0 0 12px;
  font-size: 20px;
}
.sheet-head h2 {
  margin: 0;
}
.sheet-head button {
  height: 38px;
  border-radius: 6px;
  background: #eef2f7;
  color: #111827;
}
.sheet label {
  display: block;
  margin-bottom: 12px;
  color: #4b5563;
  font-size: 13px;
}
.sheet input {
  width: 100%;
  height: 42px;
  margin-top: 6px;
  padding: 0 10px;
  border: 1px solid #d4d4d8;
  border-radius: 6px;
}
.avatar-picker {
  display: flex !important;
  align-items: center;
  gap: 12px;
}
.avatar-picker img {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  object-fit: cover;
  background: #dbe4ef;
}
.avatar-picker input {
  display: none;
}
.profile-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 4px;
}
.profile-actions button {
  width: 100%;
  height: 46px;
  border-radius: 6px;
  color: #fff;
  font-weight: 600;
}
.profile-actions #saveProfile {
  background: #07c160;
}
.danger-btn {
  background: #dc2626;
}
.viewer {
  position: fixed;
  inset: 0;
  z-index: 30;
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(12px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  overflow: hidden;
  touch-action: none;
  background: rgba(0,0,0,.92);
}
.viewer-image {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  transform-origin: center center;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.viewer-message {
  color: #fff;
  font-size: 15px;
}
