:root {
  color-scheme: light;
  --tx-chat-vh: 100vh;
  --ink: #142f42;
  --muted: #607584;
  --faint: #8a9aa6;
  --edge: rgba(255, 255, 255, 0.82);
  --line: rgba(92, 128, 148, 0.16);
  --accent: #5f77ff;
  --accent-2: #78aaff;
  --shell-shadow:
    inset 0 2px 10px rgba(255, 255, 255, 0.88),
    inset 0 -18px 32px rgba(78, 91, 146, 0.08),
    0 22px 58px rgba(47, 66, 96, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-size: 14px;
}

body {
  min-height: var(--tx-chat-vh, 100vh);
  margin: 0;
  color: var(--ink);
  font-family: "Inter", "HarmonyOS Sans SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, sans-serif;
  letter-spacing: 0;
  background:
    radial-gradient(circle at 18% 14%, rgba(120, 170, 255, 0.16), transparent 34%),
    radial-gradient(circle at 82% 10%, rgba(255, 205, 155, 0.14), transparent 30%),
    linear-gradient(145deg, #fbfdff 0%, #eef7fb 48%, #f9fcff 100%);
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.tx-chat-shell {
  min-height: var(--tx-chat-vh, 100vh);
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 42px);
}

.tx-chat-frame {
  width: min(1210px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 920px) minmax(230px, 290px);
  align-items: stretch;
  gap: 0;
}

.tx-chat-card {
  position: relative;
  width: 100%;
  height: min(760px, calc(var(--tx-chat-vh, 100vh) - 48px));
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 2px solid var(--edge);
  border-radius: 32px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.2) 72%),
    rgba(255, 255, 255, 0.34);
  box-shadow: var(--shell-shadow);
  backdrop-filter: blur(34px) saturate(176%);
  -webkit-backdrop-filter: blur(34px) saturate(176%);
}

.tx-chat-frame .tx-chat-card {
  border-radius: 32px 0 0 32px;
}

.tx-chat-side-panel {
  height: min(760px, calc(var(--tx-chat-vh, 100vh) - 48px));
  min-height: 0;
  display: grid;
  align-content: start;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  border: 2px solid var(--edge);
  border-left: 0;
  border-radius: 0 28px 28px 0;
  color: var(--ink);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.62), rgba(238, 247, 251, 0.24) 76%),
    rgba(255, 255, 255, 0.22);
  box-shadow:
    inset 0 2px 10px rgba(255, 255, 255, 0.76),
    inset 0 -18px 30px rgba(78, 91, 146, 0.05),
    14px 22px 58px rgba(47, 66, 96, 0.08);
  backdrop-filter: blur(28px) saturate(165%);
  -webkit-backdrop-filter: blur(28px) saturate(165%);
}

.tx-chat-side-block {
  min-height: 160px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 18px;
  padding: 26px 20px;
  text-align: center;
}

.tx-chat-side-block + .tx-chat-side-block {
  border-top: 1px solid rgba(92, 128, 148, 0.18);
}

.tx-chat-side-block h2 {
  margin: 0;
  color: #2f6d98;
  font-size: 1.08rem;
  font-weight: 950;
  letter-spacing: 0;
}

.tx-chat-side-block p {
  margin: 0;
  color: #263b4f;
  font-size: 1rem;
  line-height: 1.65;
  white-space: pre-line;
  word-break: break-word;
}

.tx-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.tx-chat-kicker {
  display: block;
  margin-bottom: 4px;
  color: var(--faint);
  font-size: 0.78rem;
  font-weight: 800;
}

.tx-chat-head h1 {
  margin: 0;
  font-size: clamp(1.22rem, 2.4vw, 1.68rem);
  line-height: 1.15;
}

.tx-chat-head-actions,
.tx-chat-tools,
.tx-chat-tool-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tx-chat-status {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 2px solid var(--edge);
  border-radius: 999px;
  padding: 0 13px;
  color: #3d4d78;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.34)),
    rgba(255, 255, 255, 0.3);
  box-shadow: inset 0 2px 6px rgba(255, 255, 255, 0.86);
  white-space: nowrap;
}

.tx-chat-status::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #d97b84;
  box-shadow: 0 0 0 4px rgba(217, 123, 132, 0.18);
}

.tx-chat-status.is-online::before {
  background: #4fbf7d;
  box-shadow: 0 0 0 4px rgba(79, 191, 125, 0.18);
}

.tx-chat-status.is-connecting::before {
  background: #c7a43f;
  box-shadow: 0 0 0 4px rgba(199, 164, 63, 0.18);
}

.tx-chat-icon,
.tx-chat-send {
  border: 2px solid var(--edge);
  border-radius: 999px;
  color: #304491;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.42) 58%, rgba(224, 232, 255, 0.26)),
    rgba(255, 255, 255, 0.34);
  box-shadow:
    inset 0 2px 7px rgba(255, 255, 255, 0.94),
    inset 0 -13px 20px rgba(72, 86, 150, 0.09),
    0 12px 26px rgba(52, 66, 112, 0.11);
}

.tx-chat-icon {
  width: 42px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

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

.tx-chat-icon .sound-glyph {
  width: 21px;
  height: 21px;
}

.tx-chat-reconnect {
  color: #2e78a7;
}

.tx-chat-reconnect svg {
  width: 18px;
  height: 18px;
}

.tx-chat-reconnect:hover svg {
  transform: rotate(22deg);
}

.tx-chat-reconnect.is-spinning svg {
  animation: tx-spin 0.8s linear infinite;
}

@keyframes tx-spin {
  to {
    transform: rotate(360deg);
  }
}

.tx-chat-icon .sound-slash {
  color: #ef3f54;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.tx-chat-icon .sound-wave {
  transition: opacity 0.16s ease;
}

.tx-chat-icon[aria-pressed="false"] {
  color: #748196;
}

.tx-chat-icon[aria-pressed="false"] .sound-wave {
  opacity: 0.18;
}

.tx-chat-icon[aria-pressed="false"] .sound-slash {
  opacity: 1;
}

.tx-chat-icon:hover,
.tx-chat-send:hover {
  transform: translateY(-1px);
}

.tx-chat-icon:focus-visible,
.tx-chat-send:focus-visible,
.tx-chat-compose textarea:focus-visible,
.tx-chat-emoji button:focus-visible {
  outline: 2px solid rgba(95, 119, 255, 0.48);
  outline-offset: 2px;
}

.tx-chat-body {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
  overflow: auto;
  padding: 18px;
  overscroll-behavior: contain;
}

.tx-chat-reply-tip {
  position: absolute;
  right: 18px;
  bottom: 126px;
  z-index: 8;
  display: grid;
  gap: 3px;
  max-width: min(320px, calc(100% - 36px));
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 18px;
  padding: 10px 14px;
  color: #17354c;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.88), rgba(229, 246, 255, 0.38)),
    rgba(255, 255, 255, 0.48);
  box-shadow:
    inset 0 1px 5px rgba(255, 255, 255, 0.88),
    0 16px 36px rgba(52, 83, 116, 0.16);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
  backdrop-filter: blur(22px) saturate(165%);
  -webkit-backdrop-filter: blur(22px) saturate(165%);
}

.tx-chat-reply-tip[hidden] {
  display: none;
}

.tx-chat-reply-tip.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.tx-chat-reply-tip span {
  color: #5b89a8;
  font-size: 0.76rem;
  font-weight: 900;
}

.tx-chat-reply-tip strong {
  overflow: hidden;
  color: #143247;
  font-size: 0.92rem;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tx-chat-message {
  max-width: min(82%, 620px);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.tx-chat-message.is-me {
  justify-self: end;
  justify-content: flex-end;
}

.tx-chat-avatar {
  position: relative;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  overflow: visible;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
}

.tx-chat-avatar.is-me {
  background: transparent;
}

.tx-chat-avatar.is-system {
  background: transparent;
}

.tx-chat-avatar::before {
  content: none;
}

.tx-chat-avatar::after {
  content: none;
}

.tx-chat-avatar .avatar-svg {
  display: block;
  width: 40px;
  height: 40px;
  filter: drop-shadow(0 8px 14px rgba(39, 68, 96, 0.12));
}

.tx-chat-avatar .avatar-svg--user {
  width: 39px;
  height: 39px;
}

.tx-chat-bubble {
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 20px;
  padding: 10px 13px;
  color: #22354a;
  line-height: 1.62;
  word-break: break-word;
  background: rgba(255, 255, 255, 0.56);
  box-shadow: inset 0 1px 6px rgba(255, 255, 255, 0.76);
}

.tx-chat-message.is-me .tx-chat-bubble {
  color: #fff;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), transparent 48%),
    linear-gradient(135deg, var(--accent), var(--accent-2));
}

.tx-chat-bubble img {
  display: block;
  max-width: min(310px, 100%);
  border-radius: 16px;
}

.tx-chat-image-link {
  display: inline-block;
  cursor: zoom-in;
  line-height: 0;
}

.tx-chat-compose {
  position: relative;
  display: grid;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
}

.tx-chat-compose textarea {
  width: 100%;
  min-height: 82px;
  max-height: 104px;
  resize: none;
  border: 2px solid var(--edge);
  border-radius: 22px;
  padding: 12px 14px;
  color: var(--ink);
  outline: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.28)),
    rgba(255, 255, 255, 0.24);
  box-shadow: inset 0 2px 7px rgba(255, 255, 255, 0.84);
}

.tx-chat-tools {
  justify-content: space-between;
}

.tx-chat-send {
  min-height: 40px;
  min-width: 96px;
  padding: 0 18px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), transparent 46%),
    linear-gradient(135deg, var(--accent), var(--accent-2));
}

.tx-chat-file {
  display: none;
}

.tx-chat-emoji {
  position: absolute;
  left: 14px;
  right: auto;
  bottom: 66px;
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(10, 34px);
  justify-content: start;
  gap: 2px;
  width: max-content;
  max-width: min(430px, calc(100vw - 40px));
  max-height: min(300px, 48vh);
  overflow: auto;
  border: 2px solid var(--edge);
  border-radius: 22px;
  padding: 8px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.88), rgba(255, 255, 255, 0.38)),
    rgba(255, 255, 255, 0.4);
  box-shadow:
    inset 0 2px 8px rgba(255, 255, 255, 0.92),
    0 18px 42px rgba(47, 66, 96, 0.18);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
}

.tx-chat-emoji[hidden] {
  display: none;
}

.tx-chat-emoji button {
  display: grid;
  width: 34px;
  height: 34px;
  min-width: 0;
  place-items: center;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  box-shadow: none;
  font-size: 1.35rem;
  line-height: 1;
}

.tx-chat-emoji button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.66);
}

@media (max-width: 680px) {
  .tx-chat-shell {
    padding: 10px;
    place-items: stretch;
  }

  .tx-chat-frame {
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    min-height: 0;
    height: auto;
  }

  .tx-chat-card {
    height: calc(var(--tx-chat-vh, 100vh) - 20px);
    min-height: calc(var(--tx-chat-vh, 100vh) - 20px);
    border-radius: 24px;
  }

  .tx-chat-side-panel {
    order: 2;
    height: auto;
    min-height: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto;
    border-left: 2px solid var(--edge);
    border-radius: 22px;
  }

  .tx-chat-side-block {
    min-height: 96px;
    gap: 8px;
    padding: 14px 12px;
  }

  .tx-chat-side-block + .tx-chat-side-block {
    border-top: 0;
    border-left: 1px solid rgba(92, 128, 148, 0.18);
  }

  .tx-chat-side-block h2 {
    font-size: 0.92rem;
  }

  .tx-chat-side-block p {
    font-size: 0.88rem;
  }

  .tx-chat-head {
    align-items: center;
    flex-direction: row;
    gap: 8px;
    padding: 12px 14px;
  }

  .tx-chat-head > div:first-child {
    flex: 1;
    min-width: 0;
  }

  .tx-chat-kicker {
    margin-bottom: 1px;
    font-size: 0.68rem;
  }

  .tx-chat-head h1 {
    font-size: 0.98rem;
    line-height: 1.08;
  }

  .tx-chat-head-actions {
    width: auto;
    flex: 0 0 auto;
    justify-content: flex-end;
    gap: 4px;
  }

  .tx-chat-status {
    min-height: 31px;
    padding: 0 10px;
    font-size: 0.82rem;
  }

  .tx-chat-status::before {
    width: 8px;
    height: 8px;
    box-shadow: 0 0 0 3px rgba(217, 123, 132, 0.14);
  }

  .tx-chat-status.is-online::before {
    box-shadow: 0 0 0 3px rgba(79, 191, 125, 0.14);
  }

  .tx-chat-status.is-connecting::before {
    box-shadow: 0 0 0 3px rgba(199, 164, 63, 0.14);
  }

  .tx-chat-icon {
    width: 34px;
    height: 32px;
  }

  .tx-chat-icon svg {
    width: 16px;
    height: 16px;
  }

  .tx-chat-icon .sound-glyph {
    width: 18px;
    height: 18px;
  }

  .tx-chat-reply-tip {
    right: 12px;
    bottom: 120px;
    max-width: calc(100% - 24px);
  }

  .tx-chat-message {
    max-width: 86%;
  }

  .tx-chat-emoji {
    grid-template-columns: repeat(6, 34px);
    max-width: calc(100vw - 28px);
  }
}
