:root {
  color-scheme: light;
  --ink: #20242b;
  --muted: #6d6770;
  --line: #eadccd;
  --paper: #f7eadc;
  --panel: #ffffff;
  --rose: #c9637a;
  --teal: #3b7d78;
  --gold: #a57844;
  --wechat-green: #95ec69;
  --wechat-send: #07c160;
  --chat-bg-image: none;
  --shadow: 0 22px 60px rgba(92, 64, 42, 0.16);
  --app-bg: #d8d8d8;
  --shell-bg: #ededed;
  --header-bg: #f2f2f2;
  --settings-bg: #ffffff;
  --chat-bg: #ededed;
  --composer-bg: #f6f6f6;
  --row-bg: #ffffff;
  --bubble-assistant: #ffffff;
  --bubble-assistant-tail: #ffffff;
  --bubble-user: var(--wechat-green);
  --icon-bg: #ffffff;
  --icon-ink: #252a31;
  --menu-bg: rgba(255, 255, 255, 0.98);
  --subtle-bg: #f1f3f5;
  --surface-line: rgba(0, 0, 0, 0.08);
}

:root[data-ui-style="soft"] {
  --app-bg: #e3e6e2;
  --shell-bg: #f5f6f3;
  --header-bg: #fbfbf8;
  --settings-bg: #fffdf9;
  --chat-bg: #f1f3ef;
  --composer-bg: #fbfbf8;
  --row-bg: #fffefa;
  --bubble-assistant: #fffefa;
  --bubble-assistant-tail: #fffefa;
  --bubble-user: #b8ef91;
  --icon-bg: #ffffff;
  --icon-ink: #2d3431;
  --menu-bg: rgba(255, 255, 252, 0.98);
  --subtle-bg: #edf1ec;
  --surface-line: rgba(63, 79, 67, 0.12);
  --shadow: 0 24px 70px rgba(60, 77, 64, 0.15);
}

:root[data-ui-style="night"] {
  color-scheme: dark;
  --ink: #eef2f2;
  --muted: #9aa6ad;
  --line: rgba(255, 255, 255, 0.12);
  --panel: #171d22;
  --app-bg: #111417;
  --shell-bg: #151a1e;
  --header-bg: #1b2126;
  --settings-bg: #161b20;
  --chat-bg: #11171b;
  --composer-bg: #1a2025;
  --row-bg: #1d242a;
  --bubble-assistant: #252d33;
  --bubble-assistant-tail: #252d33;
  --bubble-user: #19b867;
  --icon-bg: #262d33;
  --icon-ink: #edf1f2;
  --menu-bg: rgba(30, 37, 43, 0.98);
  --subtle-bg: #222a31;
  --surface-line: rgba(255, 255, 255, 0.1);
  --shadow: 0 28px 70px rgba(0, 0, 0, 0.32);
  --wechat-green: #19b867;
  --wechat-send: #10b961;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow: hidden;
  color: var(--ink);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: var(--app-bg);
}

button,
textarea {
  font: inherit;
}

.shell {
  width: min(1040px, calc(100vw - 28px));
  height: calc(100vh - 32px);
  min-height: 620px;
  margin: 16px auto;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  background: var(--shell-bg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.profile {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-height: 50px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--surface-line);
  background: var(--header-bg);
}

.identity {
  display: grid;
  justify-items: center;
  min-width: 0;
  gap: 2px;
  text-align: center;
}

.profile-actions {
  position: relative;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex: 0 0 auto;
  gap: 4px;
}

.custom-panel {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(90px, 0.55fr) minmax(130px, 1fr) minmax(130px, 1fr);
  gap: 10px;
  align-items: end;
  padding: 10px clamp(16px, 3vw, 28px);
  border-bottom: 1px solid var(--line);
  background: var(--settings-bg);
}

.shell.settings-open .custom-panel {
  min-height: 0;
  align-content: start;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding-top: 20px;
  overflow-y: auto;
  background: var(--settings-bg);
}

.shell.settings-open {
  grid-template-rows: auto 1fr;
}

.custom-panel[hidden] {
  display: none;
}

.custom-panel label {
  display: grid;
  gap: 5px;
  min-width: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.custom-panel input[type="text"] {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--row-bg);
  outline: none;
}

.custom-panel input[type="file"] {
  width: 100%;
  min-width: 0;
  height: 38px;
  color: var(--muted);
  font-size: 12px;
}

.custom-panel input[type="file"]::file-selector-button {
  height: 34px;
  margin-right: 8px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  color: var(--icon-ink);
  background: var(--subtle-bg);
  cursor: pointer;
}

.wide-field {
  grid-column: span 2;
}

.reset-media {
  display: flex;
  gap: 8px;
  align-items: end;
}

.settings-links {
  display: flex;
  gap: 8px;
  align-items: end;
}

.reset-media button,
.settings-links button {
  min-height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: var(--subtle-bg);
  cursor: pointer;
}

.custom-panel input[type="range"] {
  width: 100%;
  accent-color: var(--rose);
}

.ui-style-picker {
  display: flex;
  gap: 8px;
  align-items: center;
  padding-bottom: 2px;
}

.ui-style-choice {
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--row-bg);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.ui-style-choice.active {
  color: #fff;
  border-color: var(--wechat-send);
  background: var(--wechat-send);
}

.voice-badge {
  padding: 6px 9px;
  border: 1px solid rgba(216, 222, 232, 0.95);
  border-radius: 999px;
  color: var(--teal);
  background: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.avatar-mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  color: white;
  background: linear-gradient(150deg, #c9637a, #7a5b4a);
  background-position: center;
  background-size: cover;
  box-shadow: 0 12px 28px rgba(121, 79, 54, 0.2);
}

.avatar-mark.has-image {
  background-color: #ddd;
  background-image: var(--top-avatar-image);
}

.avatar-mark span {
  font-size: 19px;
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  max-width: 48vw;
  overflow: hidden;
  font-size: 20px;
  line-height: 1.18;
  letter-spacing: 0;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.status {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.chat {
  position: relative;
  min-height: 0;
  height: 100%;
  padding: 12px clamp(14px, 3vw, 24px);
  overflow: hidden;
  background: var(--chat-bg);
  overscroll-behavior: contain;
}

.chat::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background-image: var(--chat-bg-image);
  background-position: center;
  background-size: cover;
  opacity: 0.36;
}

.shell.has-chat-bg .chat::before {
  opacity: 0.68;
}

.messages {
  position: relative;
  z-index: 2;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scroll-behavior: smooth;
}

.message-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  align-items: flex-end;
  column-gap: 8px;
  width: 100%;
  min-width: 0;
  overflow: visible;
}

.message-row.user {
  grid-template-columns: minmax(0, 1fr) 36px;
}

.message-row.user .message-avatar {
  grid-column: 2;
}

.message-row.image-only {
  margin-top: -4px;
}

.message-avatar.spacer {
  visibility: hidden;
  box-shadow: none;
}

.message-row.user.image-only .message-avatar.spacer {
  grid-column: 2;
}

.message-avatar {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
  border-radius: 6px;
  color: white;
  background: linear-gradient(150deg, #c9637a, #7a5b4a);
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.message-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.message-row.user .message-avatar {
  background: #3b7d78;
}

.message {
  width: fit-content;
  max-width: min(62ch, 88%);
  min-width: 0;
  justify-self: start;
  position: relative;
  padding: 9px 11px;
  border: 0;
  border-radius: 5px;
  line-height: 1.52;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  word-break: break-word;
}

.message-row.user .message {
  justify-self: end;
}

.message.assistant {
  background: var(--bubble-assistant);
}

.message.user {
  color: #111;
  border-color: transparent;
  background: var(--bubble-user);
}

.media-message {
  padding: 4px;
  overflow: hidden;
  background: transparent;
}

.message.assistant.media-message,
.message.user.media-message {
  background: transparent;
}

.media-message::before {
  display: none;
}

.message.assistant::before,
.message.user::before {
  content: "";
  position: absolute;
  top: 12px;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
}

.message.assistant::before {
  left: -5px;
  border-right: 6px solid var(--bubble-assistant-tail);
}

.message.user::before {
  right: -5px;
  border-left: 6px solid var(--bubble-user);
}

.composer {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px 44px 62px;
  grid-template-areas: "voice input image sticker send";
  gap: 8px;
  align-items: center;
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--surface-line);
  background: var(--composer-bg);
}

.hidden-file {
  display: none;
}

.image-button,
.sticker-button {
  display: grid;
  place-items: center;
  color: var(--teal);
  font-size: 15px;
  font-weight: 800;
}

.sticker-panel {
  position: absolute;
  right: 10px;
  bottom: 64px;
  z-index: 9;
  width: min(360px, calc(100vw - 20px));
  max-height: min(320px, 45vh);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
  border-radius: 8px;
  background: var(--menu-bg);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.18);
}

.sticker-panel[hidden] {
  display: none;
}

.sticker-choice {
  min-height: 36px;
  border: 0;
  border-radius: 8px;
  color: var(--icon-ink);
  background: transparent;
  font-size: 24px;
  cursor: pointer;
}

.sticker-choice:hover {
  background: var(--subtle-bg);
}

.sticker-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 10px;
  overflow-x: auto;
  border-bottom: 1px solid var(--surface-line);
  background: var(--composer-bg);
}

.sticker-tab {
  flex: 0 0 44px;
  height: 38px;
  border: 0;
  border-radius: 6px;
  color: var(--icon-ink);
  background: transparent;
  font-size: 21px;
  cursor: pointer;
}

.sticker-tab.active,
.sticker-tab:hover {
  background: var(--subtle-bg);
}

.sticker-content {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  align-content: start;
  gap: 5px;
  padding: 10px;
  overflow-y: auto;
}

.emoji-section {
  grid-column: 1 / -1;
  padding: 4px 4px 2px;
  color: #8a8f98;
  font-size: 12px;
  font-weight: 700;
}

.sticker-manage-heading {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--muted);
  font-size: 13px;
}

.sticker-manage-heading span {
  margin-right: auto;
}

.custom-sticker-add {
  min-height: 30px;
  padding: 0 12px;
  border: 0;
  border-radius: 4px;
  color: #fff;
  background: var(--teal);
}

.sticker-empty {
  grid-column: 1 / -1;
  margin: 18px 2px;
  color: var(--muted);
  font-size: 13px;
}

.image-sticker-wrap {
  position: relative;
  aspect-ratio: 1;
}

.image-sticker-choice {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  background: var(--subtle-bg);
  cursor: pointer;
}

.image-sticker-choice img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remove-sticker {
  position: absolute;
  top: -5px;
  right: -5px;
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: rgba(28, 32, 36, 0.78);
  font-size: 15px;
}

.chat-image {
  display: block;
  width: min(240px, 64vw);
  aspect-ratio: 3 / 4;
  max-height: min(420px, 62vh);
  margin: 0;
  border-radius: 6px;
  object-fit: cover;
  background: #eee;
}

.sticker-image {
  width: min(168px, 46vw);
  aspect-ratio: 1 / 1;
  max-height: none;
  background: transparent;
}

.sticker-bubble {
  min-width: 96px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.55);
  font-weight: 800;
}

.composer > * {
  min-width: 0;
}

textarea {
  width: 100%;
  max-height: 120px;
  resize: none;
  grid-area: input;
  min-height: 42px;
  padding: 9px 12px;
  border: 0;
  border-radius: 4px;
  color: var(--ink);
  background: var(--panel);
  outline: none;
}

textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(36, 123, 123, 0.12);
}

.shell.sticker-open {
  grid-template-rows: auto minmax(0, 1fr) auto minmax(220px, 36vh);
}

.shell.sticker-open .sticker-panel {
  position: static;
  width: 100%;
  max-height: none;
  border-radius: 0;
  box-shadow: none;
}

.icon-button,
.top-icon,
.send {
  min-height: 40px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
}

.icon-button {
  position: relative;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--icon-bg);
  color: var(--icon-ink);
  box-shadow: inset 0 0 0 1px var(--surface-line);
}

.icon-button::before,
.icon-button::after {
  content: none;
}

.icon-button svg {
  width: 23px;
  height: 23px;
  display: block;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.voice {
  grid-area: voice;
}

.voice.holding,
.voice.active {
  color: white;
  background: var(--wechat-send);
  box-shadow: inset 0 0 0 1px var(--wechat-send);
}

.image-button {
  grid-area: image;
}

.sticker-button {
  grid-area: sticker;
}

.top-icon {
  position: relative;
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  color: var(--icon-ink);
  font-size: 20px;
  background: transparent;
}

.back-button {
  display: inline-grid;
  font-size: 32px;
  font-weight: 300;
  line-height: 1;
}

.shell.chat-open .back-button {
  display: inline-grid;
  place-items: center;
}

.shell.settings-open .back-button {
  display: inline-grid;
  place-items: center;
}

.menu-button {
  font-size: 24px;
  letter-spacing: 2px;
}

.top-menu {
  position: absolute;
  top: 46px;
  right: 0;
  z-index: 40;
  width: 168px;
  display: grid;
  padding: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  background: var(--menu-bg);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.16);
}

.top-menu[hidden] {
  display: none;
}

.top-menu button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  color: var(--ink);
  background: transparent;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
}

.top-menu button:hover {
  background: var(--subtle-bg);
}

.conversation-list {
  min-height: 0;
  padding: 0;
  background: var(--shell-bg);
}

.conversation-item {
  width: 100%;
  min-height: 78px;
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: center;
  padding: 12px clamp(14px, 3vw, 28px);
  border: 0;
  border-bottom: 1px solid var(--surface-line);
  color: var(--ink);
  background: var(--row-bg);
  text-align: left;
  cursor: pointer;
}

.conversation-item:hover {
  background: var(--subtle-bg);
}

.contact-avatar {
  width: 48px;
  height: 48px;
  border-radius: 8px;
}

.conversation-main {
  min-width: 0;
}

.conversation-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.conversation-top strong {
  font-size: 16px;
}

.conversation-top span {
  flex: 0 0 auto;
  color: #8a8f98;
  font-size: 12px;
}

.conversation-main p {
  margin: 0;
  color: #6d7480;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shell:not(.chat-open) .chat,
.shell:not(.chat-open) .composer,
.shell:not(.chat-open) .custom-panel {
  display: none;
}

.shell.chat-open .conversation-list {
  display: none;
}

.shell.settings-open .conversation-list,
.shell.settings-open .chat,
.shell.settings-open .composer,
.shell.settings-open .sticker-panel,
.shell.history-open .conversation-list,
.shell.history-open .chat,
.shell.history-open .composer,
.shell.history-open .custom-panel,
.shell.history-open .sticker-panel,
.shell.intimacy-open .conversation-list,
.shell.intimacy-open .chat,
.shell.intimacy-open .composer,
.shell.intimacy-open .custom-panel,
.shell.intimacy-open .sticker-panel,
.shell.admin-open .conversation-list,
.shell.admin-open .chat,
.shell.admin-open .composer,
.shell.admin-open .custom-panel,
.shell.admin-open .sticker-panel {
  display: none;
}

.shell.settings-open .custom-panel {
  display: grid;
}

.history-panel,
.intimacy-panel,
.admin-panel {
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  background: var(--settings-bg);
}

.history-panel[hidden],
.intimacy-panel[hidden],
.admin-panel[hidden] {
  display: none;
}

.shell.history-open .history-panel,
.shell.intimacy-open .intimacy-panel,
.shell.admin-open .admin-panel {
  display: grid;
  align-content: start;
  gap: 14px;
}

.panel-heading {
  display: grid;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--surface-line);
}

.panel-heading strong {
  font-size: 18px;
}

.panel-heading span,
.empty-note,
.intimacy-copy {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  background: var(--row-bg);
}

.history-item.user {
  border-color: rgba(7, 193, 96, 0.26);
}

.history-meta {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.history-item p {
  margin: 0;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.history-item img {
  width: min(260px, 72vw);
  max-height: 420px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--subtle-bg);
}

.download-link {
  width: fit-content;
  color: var(--wechat-send);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.admin-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.admin-stat,
.admin-block,
.admin-row {
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  background: var(--row-bg);
}

.admin-stat {
  display: grid;
  gap: 5px;
  padding: 12px;
}

.admin-stat span,
.admin-stat em,
.admin-row span,
.admin-row small {
  color: var(--muted);
  font-style: normal;
  font-size: 12px;
}

.admin-stat strong {
  font-size: 18px;
}

.admin-block {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.admin-block-title,
.admin-inline-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-inline-actions input {
  width: 72px;
  height: 36px;
  padding: 0 8px;
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
}

.admin-block button,
.admin-row-actions button {
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: 8px;
  color: var(--icon-ink);
  background: var(--subtle-bg);
  font-weight: 800;
  cursor: pointer;
}

.admin-block button.danger,
.admin-row-actions button.danger {
  color: #fff;
  background: #fa5151;
}

.admin-list {
  display: grid;
  gap: 8px;
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
}

.admin-row-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.admin-row-main strong,
.admin-row-main span {
  overflow-wrap: anywhere;
}

.admin-row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.invite-used,
.user-disabled {
  opacity: 0.72;
}

.invite-revoked {
  border-color: rgba(250, 81, 81, 0.28);
}

.intimacy-meter {
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  background: var(--row-bg);
}

.intimacy-track {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--subtle-bg);
}

.intimacy-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--wechat-send);
  transition: width 0.25s ease;
}

.intimacy-labels {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  text-align: center;
}

.admin-intimacy {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  background: var(--row-bg);
}

.admin-intimacy[hidden] {
  display: none;
}

.admin-intimacy label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.admin-intimacy input {
  width: 100%;
  accent-color: var(--wechat-send);
}

.admin-intimacy button {
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--wechat-send);
  font-weight: 800;
  cursor: pointer;
}

.conversation-item.has-unread {
  position: relative;
}

.conversation-item.has-unread::after {
  content: var(--unread-count);
  position: absolute;
  top: 12px;
  left: 48px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: #fa5151;
  font-size: 11px;
  font-weight: 800;
}

.icon-button.active,
.top-icon.active {
  background: rgba(217, 87, 124, 0.2);
  box-shadow: inset 0 0 0 2px rgba(217, 87, 124, 0.34);
}

.speaker-icon {
  position: absolute;
  left: 8px;
  top: 13px;
  width: 11px;
  height: 12px;
  background: currentColor;
  clip-path: polygon(0 30%, 38% 30%, 100% 0, 100% 100%, 38% 70%, 0 70%);
}

.speaker-icon::before,
.speaker-icon::after {
  content: "";
  position: absolute;
  border: 2px solid currentColor;
  border-left: 0;
  border-top-color: transparent;
  border-bottom-color: transparent;
  border-radius: 50%;
}

.top-icon:not(.active) .speaker-icon::before,
.top-icon:not(.active) .speaker-icon::after {
  display: none;
}

.speaker-icon::before {
  left: 12px;
  top: -2px;
  width: 7px;
  height: 14px;
}

.speaker-icon::after {
  left: 16px;
  top: -6px;
  width: 12px;
  height: 22px;
}

.send {
  grid-area: send;
  min-height: 40px;
  padding: 0 14px;
  color: white;
  font-weight: 600;
  background: var(--wechat-send);
  border-radius: 8px;
}

.send:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
}

.auth-locked {
  filter: saturate(0.82);
}

.logout-button {
  font-size: 15px;
  font-weight: 800;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(32, 36, 43, 0.28);
  backdrop-filter: blur(10px);
}

.confirm-dialog {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.32);
}

.confirm-dialog[hidden] {
  display: none;
}

.confirm-card {
  width: min(320px, calc(100vw - 40px));
  display: grid;
  gap: 12px;
  padding: 18px;
  border-radius: 8px;
  background: var(--menu-bg);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.28);
}

.confirm-card strong {
  font-size: 17px;
}

.confirm-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.confirm-actions button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  font-weight: 800;
  cursor: pointer;
}

#confirmCancel {
  color: var(--ink);
  background: var(--subtle-bg);
}

#confirmOk {
  color: #fff;
  background: #fa5151;
}

.auth-gate[hidden] {
  display: none;
}

.auth-card {
  width: min(380px, calc(100vw - 32px));
  display: grid;
  gap: 14px;
  padding: 24px;
  border-radius: 8px;
  background: var(--menu-bg);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.22);
}

.auth-card h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
}

.auth-copy {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.auth-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.auth-card label[hidden] {
  display: none;
}

.auth-card input {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--surface-line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  outline: none;
}

.auth-card input:focus {
  border-color: var(--wechat-send);
  box-shadow: 0 0 0 3px rgba(7, 193, 96, 0.13);
}

.auth-submit,
.auth-switch {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.auth-submit {
  color: white;
  font-weight: 800;
  background: var(--wechat-send);
}

.auth-submit:disabled {
  cursor: wait;
  opacity: 0.65;
}

.auth-switch {
  color: var(--teal);
  font-weight: 700;
  background: var(--subtle-bg);
}

.auth-error {
  min-height: 20px;
  margin: 0;
  color: #c43d4b;
  font-size: 13px;
}

@media (max-width: 640px) {
  html,
  body {
    width: 100%;
    height: 100%;
    min-height: 100dvh;
    overflow: hidden;
  }

  .shell {
    width: 100vw;
    height: 100dvh;
    min-height: 100dvh;
    margin: 0;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    grid-template-rows: auto 1fr auto;
    overflow: hidden;
  }

  .profile {
    padding: 8px 10px;
    gap: 8px;
  }

  .identity {
    gap: 8px;
  }

  .voice-badge {
    display: none;
  }

  .custom-panel {
    grid-template-columns: 1fr 92px;
    gap: 9px;
    padding: 10px 12px;
  }

  .shell.settings-open .custom-panel {
    grid-template-columns: 1fr;
    padding: 14px 12px calc(22px + env(safe-area-inset-bottom));
  }

  .upload-field,
  .wide-field,
  .reset-media,
  .settings-links {
    grid-column: 1 / -1;
  }

  .ui-style-picker {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .avatar-mark {
    width: 34px;
    height: 34px;
  }

  h1 {
    font-size: 19px;
  }

  .status {
    max-width: 48vw;
    margin-top: 2px;
    overflow: hidden;
    font-size: 12px;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .chat {
    display: block;
    min-height: 0;
    height: 100%;
    padding: 8px 10px;
    overflow: hidden;
  }

  .messages {
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 0;
    gap: 8px;
    min-height: 0;
    padding-bottom: 8px;
  }

  .message {
    width: auto;
    max-width: calc(100vw - 118px);
    font-size: 14px;
    line-height: 1.45;
  }

  .message-row.user .message {
    max-width: calc(100vw - 132px);
  }

  .message-avatar {
    width: 34px;
    height: 34px;
    font-size: 12px;
  }

  .message-row {
    grid-template-columns: 34px minmax(0, 1fr);
    column-gap: 8px;
    overflow: visible;
  }

  .message-row.user {
    grid-template-columns: minmax(0, 1fr) 34px;
  }

  .composer {
    grid-template-columns: 38px minmax(0, 1fr) 38px 38px 50px;
    grid-template-areas: "voice input image sticker send";
    gap: 6px;
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  }

  .shell.sticker-open {
    grid-template-rows: auto minmax(0, 1fr) auto minmax(238px, 38dvh);
  }

  .sticker-content {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 7px;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  .icon-button svg {
    width: 19px;
    height: 19px;
  }

  .composer textarea {
    grid-area: input;
    min-height: 38px;
    max-height: 76px;
    line-height: 1.35;
  }

  .composer .voice {
    grid-area: voice;
  }

  .composer .image-button {
    grid-area: image;
  }

  .composer .sticker-button {
    grid-area: sticker;
  }

  .send {
    grid-area: send;
    min-height: 38px;
    padding: 0 8px;
    font-size: 14px;
  }

  .admin-overview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-row {
    grid-template-columns: 1fr;
  }

  .admin-row-actions {
    justify-content: flex-start;
  }

  .auth-card {
    padding: 20px;
  }

  .auth-card h2 {
    font-size: 24px;
  }
}
