:root {
  --green: #07C160;
  --green-hover: #06AD56;
  --green-down: #038D4A;
  --green-disabled: #B7E6C8;
  --nav: #2E2E2E;
  --page: #EDEDED;
  --sheet: #F5F5F5;
  --self: #95EC69;
  --other: #FFFFFF;
  --line: #E5E5E5;
  --text: #1A1A1A;
  --sub: #9A9A9A;
  --danger: #FA5151;
  --app-h: 100dvh;
  color-scheme: light;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #DCDCDC; }
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; }
button, a { -webkit-tap-highlight-color: transparent; }

#app {
  width: min(480px, 100%);
  height: var(--app-h);
  margin: 0 auto;
  background: var(--page);
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.view[hidden],
.roles[hidden],
.role[hidden],
.field[hidden],
.btn[hidden] { display: none; }

.login {
  flex: 1;
  background: #fff;
  padding: calc(18vh + env(safe-area-inset-top)) 36px 32px;
}
.brand {
  margin: 0 0 36px;
  text-align: center;
  font-size: 32px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--text);
}
.roles {
  display: flex;
  gap: 28px;
  margin: 0 0 28px;
}
.role {
  position: relative;
  height: 32px;
  font-size: 16px;
  color: var(--sub);
}
.role.on { color: var(--green); }
.role.on::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--green);
}
.field {
  display: block;
  border-bottom: 1px solid var(--line);
}
.field input {
  width: 100%;
  height: 52px;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 16px;
}
.field input::placeholder { color: #C4C4C4; }
.err {
  min-height: 22px;
  margin: 14px 0 8px;
  color: var(--danger);
  font-size: 13px;
}
.btn {
  width: 100%;
  height: 44px;
  margin-top: 12px;
  border-radius: 4px;
  background: var(--green);
  color: #fff;
  font-size: 16px;
}
.btn:active { background: var(--green-down); }
.btn:disabled { background: var(--green-disabled); }

.bar {
  position: relative;
  flex: none;
  height: calc(48px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  background: var(--page);
  display: flex;
  align-items: center;
  justify-content: center;
}
.bar h1 {
  margin: 0;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
}
.text-btn {
  position: absolute;
  right: 16px;
  bottom: 0;
  height: 48px;
  color: var(--sub);
  font-size: 15px;
}
.net-bar {
  flex: none;
  background: #F7F7F7;
  color: var(--sub);
  text-align: center;
  font-size: 13px;
  line-height: 32px;
}

#view-main { padding-top: env(safe-area-inset-top); }
.pane { flex: 1; min-height: 0; overflow-y: auto; background: #fff; -webkit-overflow-scrolling: touch; }
.pane[hidden] { display: none; }
.empty {
  padding: 72px 24px;
  text-align: center;
  color: #B0B0B0;
  font-size: 14px;
  background: var(--sheet);
}
.section-label {
  padding: 8px 16px 4px;
  background: var(--sheet);
  color: var(--sub);
  font-size: 12px;
}

.row {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 11px 16px;
  text-align: left;
  background: #fff;
  border-bottom: 1px solid #F0F0F0;
}
.row:active { background: var(--page); }
.avatar {
  position: relative;
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 4px;
  background: #E8E8E8;
  color: var(--text);
  font-size: 18px;
  display: grid;
  place-items: center;
}
.avatar .face {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}
.avatar .letter { position: relative; }
.dot {
  position: absolute;
  right: -1px;
  bottom: -1px;
  z-index: 2;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid #fff;
}
.row-main { flex: 1; min-width: 0; }
.row-top, .row-bot {
  display: flex;
  align-items: center;
  gap: 6px;
}
.row-bot { margin-top: 4px; }
.name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 16px;
  color: #191919;
}
.time { flex: none; color: #B2B2B2; font-size: 12px; }
.preview {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--sub);
  font-size: 13px;
}
.badge {
  flex: none;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  font-style: normal;
}
.tag {
  flex: none;
  padding: 0 4px;
  border-radius: 2px;
  background: #E8F6EE;
  color: var(--green);
  font-size: 10px;
  line-height: 16px;
}
.tag.group { background: #F2F2F2; color: #888; }

.tabs {
  flex: none;
  height: calc(52px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #F7F7F7;
  border-top: 1px solid var(--line);
  display: flex;
}
.tab {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #7F7F7F;
  font-size: 11px;
}
.tab svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.tab.on { color: var(--green); }
.tab-badge {
  position: absolute;
  top: 4px;
  left: calc(50% + 8px);
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  line-height: 16px;
  font-style: normal;
}

.chat-bar { background: var(--page); }
.back {
  position: absolute;
  left: 4px;
  bottom: 0;
  width: 44px;
  height: 48px;
}
.back::before {
  content: "";
  position: absolute;
  left: 16px;
  top: 17px;
  width: 10px;
  height: 10px;
  border-left: 2px solid var(--text);
  border-bottom: 2px solid var(--text);
  transform: rotate(45deg);
}
.msgs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 12px 8px;
  background: var(--page);
  -webkit-overflow-scrolling: touch;
}
.time-chip {
  margin: 8px 0;
  text-align: center;
  color: #B2B2B2;
  font-size: 12px;
}
.bubble-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 8px 0;
}
.bubble-row.self { flex-direction: row-reverse; align-items: flex-end; }
.read-mark {
  flex: none;
  margin-bottom: 2px;
  font-size: 11px;
  line-height: 1;
  color: #4A90E2;
}
.read-mark.on { color: #B2B2B2; }
.bubble-col { max-width: 72%; }
.who {
  margin: 0 0 4px 2px;
  color: var(--sub);
  font-size: 12px;
}
.bubble {
  padding: 9px 12px;
  border-radius: 4px;
  background: var(--other);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.self .bubble { background: var(--self); }
.bubble.fail { outline: 1px solid var(--danger); }
.bubble.media { padding: 0; background: transparent; }
.msg-img, .msg-sticker {
  display: block;
  border-radius: 4px;
  background: #E8E8E8;
}
.msg-img {
  width: min(220px, 62vw);
  height: auto;
  max-height: 220px;
  object-fit: contain;
}
.msg-sticker {
  width: 120px;
  height: 120px;
  object-fit: contain;
  background: transparent;
}
.msg-ph {
  display: grid;
  place-items: center;
  width: 120px;
  height: 88px;
  border-radius: 4px;
  background: #E8E8E8;
  color: var(--sub);
  font-size: 13px;
}
.sys {
  margin: 10px 24px;
  text-align: center;
  color: var(--sub);
  font-size: 12px;
  line-height: 1.4;
}
.composer {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 10px;
  background: #F7F7F7;
  border-top: 1px solid var(--line);
}
#view-chat:not(:has(.sticker-panel:not([hidden]))) .composer {
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
}
.tool {
  flex: none;
  width: 34px;
  height: 34px;
  color: #4C4C4C;
}
.tool.on { color: var(--green); }
.tool svg {
  width: 26px;
  height: 26px;
  display: block;
  margin: 4px auto 0;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linejoin: round;
  stroke-linecap: round;
}
.sticker-panel {
  flex: none;
  display: flex;
  flex-direction: column;
  height: calc(248px + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: #F7F7F7;
  border-top: 1px solid var(--line);
}
.sticker-panel[hidden], .viewer[hidden] { display: none; }
.sticker-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 8px 10px 0;
}
.sticker-tab {
  flex: none;
  height: 28px;
  padding: 0 10px;
  border-radius: 14px;
  color: var(--sub);
  font-size: 13px;
}
.sticker-tab.on { background: #fff; color: var(--text); }
.sticker-grid {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  align-content: start;
  overflow-y: auto;
  padding: 10px 12px 12px;
}
.sticker-item {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}
.sticker-item img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}
.viewer {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.92);
}
.viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.composer textarea {
  flex: 1;
  max-height: 96px;
  resize: none;
  border: 0;
  border-radius: 4px;
  outline: 0;
  background: #fff;
  padding: 8px 10px;
  font-size: 16px;
  line-height: 1.4;
}
.send {
  flex: none;
  height: 34px;
  padding: 0 12px;
  border-radius: 4px;
  background: var(--green);
  color: #fff;
  font-size: 15px;
}
.send:disabled { background: var(--green-disabled); }
.send:active:not(:disabled) { background: var(--green-down); }
