/* Chat UI + Rooms - legacy browser friendly */
:root {
  --chat-bg: #e8eeef;
  --chat-bubble-me: #2f7f8f;
  --chat-bubble-other: #ffffff;
  --chat-border: #d5e0e2;
}

body.chat-page {
  background: #e8eeef;
}

html {
  height: 100%;
}

body.chat-page:not(.rooms-page) {
  height: 100%;
  overflow: hidden;
  padding-bottom: 0;
}

.chat-header-inner {
  width: 100%;
}

.chat-cs-name {
  flex: 1;
  min-width: 0;
  font-size: 16px;
  font-weight: 600;
  color: #152844;
  line-height: 36px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-inner .h5-logo {
  text-decoration: none;
}

.chat-header-inner .chat-topbar-clear {
  float: none;
  margin: 0 0 0 auto;
  flex-shrink: 0;
}

.rooms-shell {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 20px 56px;
}

body.rooms-page {
  font-family: 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  background:
    radial-gradient(ellipse 90% 55% at 12% -10%, rgba(86, 176, 230, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 45% at 92% 8%, rgba(37, 99, 160, 0.12), transparent 50%),
    linear-gradient(180deg, #eef5fb 0%, #f7fafc 42%, #f3f6f9 100%);
  color: #16304a;
  padding-bottom: 0;
}

body.rooms-page .rooms-header {
  background: rgba(255, 255, 255, 0.78);
  border-bottom: 1px solid rgba(180, 202, 220, 0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

body.rooms-page .rooms-header .title {
  font-family: 'Noto Serif SC', 'Songti SC', serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: #10253a;
  line-height: 36px;
}

body.rooms-page .chat-topbar-home {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  float: none;
  width: auto;
  padding: 0;
  overflow: visible;
}

body.rooms-page .chat-topbar-home > div:first-child {
  float: none;
  max-width: none;
  flex: 1;
  min-width: 0;
}

body.rooms-page .chat-topbar-home > .chat-btn-outline {
  float: none;
  margin-left: auto;
}

body.rooms-page .h5-header-inner {
  align-items: center;
}

.rooms-hero {
  position: relative;
  overflow: hidden;
  min-height: 280px;
  padding: 56px 48px;
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(10, 28, 48, 0.92) 0%, rgba(18, 58, 98, 0.88) 48%, rgba(56, 140, 190, 0.72) 100%),
    radial-gradient(circle at 78% 28%, rgba(165, 216, 253, 0.35), transparent 42%);
  color: #fff;
  box-shadow: 0 28px 60px rgba(16, 42, 72, 0.18);
  animation: rooms-hero-in 0.7s ease both;
}

.rooms-hero-mist {
  position: absolute;
  inset: -20% -10% auto auto;
  width: 58%;
  height: 140%;
  background:
    radial-gradient(ellipse at 40% 40%, rgba(186, 230, 255, 0.28), transparent 62%),
    radial-gradient(ellipse at 70% 70%, rgba(120, 190, 235, 0.18), transparent 55%);
  animation: rooms-mist 12s ease-in-out infinite alternate;
  pointer-events: none;
}

.rooms-hero-copy {
  position: relative;
  z-index: 1;
  max-width: 520px;
  animation: rooms-copy-in 0.85s 0.08s ease both;
}

.rooms-hero h1 {
  margin: 0;
  font-family: 'Noto Serif SC', 'Songti SC', serif;
  font-size: 48px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.14em;
}

.rooms-hero p {
  margin: 16px 0 0;
  max-width: 420px;
  font-size: 16px;
  line-height: 1.7;
  color: rgba(236, 246, 255, 0.86);
  letter-spacing: 0.06em;
}

.rooms-hero-cta,
.rooms-hero .chat-btn {
  margin-top: 28px;
  height: 46px;
  padding: 0 28px;
  border-radius: 999px;
  background: #fff;
  color: #123554;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 28px rgba(8, 24, 42, 0.22);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.rooms-hero-cta:hover,
.rooms-hero .chat-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(8, 24, 42, 0.28);
}

@keyframes rooms-hero-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes rooms-copy-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes rooms-mist {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(-4%, 3%, 0) scale(1.06);
  }
}

.rooms-panel {
  margin-top: 36px;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.rooms-panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: visible;
  margin-bottom: 18px;
}

.rooms-panel-head h2 {
  float: none;
  margin: 0;
  flex: 1;
  font-family: 'Noto Serif SC', 'Songti SC', serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #13293f;
}

.rooms-panel-head .chat-btn-outline {
  float: none;
  height: 36px;
  line-height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  border-color: rgba(148, 174, 198, 0.55);
  color: #3a5570;
  background: rgba(255, 255, 255, 0.7);
}

.rooms-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid rgba(178, 200, 220, 0.55);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.88);
}

.room-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(178, 200, 220, 0.42);
  background: transparent;
  transition: background 0.15s ease;
}

.room-row:last-child {
  border-bottom: none;
}

.room-row:hover {
  background: #f7fafc;
}

.room-row-main {
  min-width: 0;
  flex: 1;
}

.room-row-title-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex-wrap: wrap;
}

.room-row-name {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #13293f;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 100%;
}

.room-row-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  font-size: 12px;
  color: #7b90a6;
}

.room-row-side {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.room-row-actions,
.room-row-admin {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.room-row-actions .chat-btn,
.room-row-actions .chat-btn-outline,
.room-row-admin .chat-btn-outline {
  height: 32px;
  line-height: 30px;
  padding: 0 12px;
  font-size: 13px;
  border-radius: 8px;
  float: none;
}

.room-row-cs .room-enter-btn {
  background: #0f766e;
}

.room-badge {
  display: inline-block;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: #6d859c;
  font-size: 12px;
  font-weight: 500;
  flex: 0 0 auto;
}

.room-created {
  color: #94a3b8;
}

.room-slug {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: #7b90a6;
  word-break: break-all;
}

.room-enter-btn {
  text-align: center;
  box-sizing: border-box;
}

.room-kind {
  display: inline-block;
  flex: 0 0 auto;
  margin: 0;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  letter-spacing: 0.04em;
  font-weight: 600;
  line-height: 1.4;
  background: rgba(148, 163, 184, 0.12);
}

.room-kind-cs {
  color: #0f766e;
  background: rgba(15, 118, 110, 0.1);
}

.room-kind-room {
  color: #64748b;
}




.rooms-empty {
  padding: 48px 10px 24px;
  text-align: center;
  color: #8b98ab;
  letter-spacing: 0.04em;
}

.room-qr-box {
  max-width: 360px;
}

.room-qr-wrap {
  text-align: center;
  margin: 8px 0 14px;
}

.room-qr-image {
  width: 240px;
  height: 240px;
  margin: 0 auto;
  border-radius: 14px;
  border: 1px solid #e5e7eb;
  background: #fff;
  padding: 10px;
  text-align: center;
}

.room-qr-image img,
.room-qr-image canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.room-share-link {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  color: #475569;
  font-size: 12px;
  word-break: break-all;
}

.room-copy-state {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #ecfdf5;
  border: 1px solid #bbf7d0;
  color: #166534;
  font-size: 12px;
}

.chat-toast {
  position: fixed;
  left: 50%;
  top: 70px;
  z-index: 30000;
  min-width: 160px;
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.92);
  color: #fff;
  text-align: center;
  font-size: 13px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.2);
  transform: translateX(-50%);
  -webkit-transform: translateX(-50%);
}

.layui-layer .chat-modal-box {
  width: auto;
  max-width: none;
  margin: 0;
}

@media (max-width: 768px) {
  .layui-layer {
    width: 92% !important;
    left: 50% !important;
    margin-left: 0 !important;
    transform: translateX(-50%);
    -webkit-transform: translateX(-50%);
  }

  .layui-layer .chat-modal-box {
    width: 100%;
    box-sizing: border-box;
  }
}

.chat-shell {
  max-width: 1108px;
  margin: 0 auto;
  min-height: 0;
  position: relative;
  height: calc(100vh - var(--header-h));
  padding-bottom: 0;
}

.chat-topbar-room {
  width: auto;
}

.chat-topbar-room > div:first-child {
  max-width: calc(100% - 190px);
}

.chat-topbar-room:after {
  content: '';
  display: block;
  clear: both;
}

.chat-topbar-back {
  height: 32px;
  line-height: 30px;
  border-radius: 16px;
}

.chat-topbar-home {
  width: auto;
}

.chat-topbar-home > div:first-child {
  float: left;
  max-width: calc(100% - 130px);
}

.chat-topbar-home:after {
  content: '';
  display: block;
  clear: both;
}

.chat-topbar-home .title,
.chat-topbar-home .meta {
  display: block;
}

.chat-topbar {
  padding: 10px 12px;
  overflow: hidden;
}

.chat-topbar > div:first-child {
  float: left;
}

.chat-topbar > .chat-btn-outline,
.chat-topbar > .h5-btn-login,
.chat-topbar > button,
.chat-topbar > a {
  float: right;
}

.chat-topbar-clear {
  margin-right: 8px;
  color: #b91c1c;
  border-color: #fecaca;
  background: #fef2f2;
}

.admin-login-panel {
  max-width: 460px;
  margin: 24px auto 0;
}

.admin-login-panel h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.chat-bubble.recalled,
.chat-row.me .chat-bubble.recalled {
  background: #f3f4f6;
  border-color: #e5e7eb;
  color: #6b7280;
  font-style: italic;
}

.chat-row.me .chat-bubble.recalled .label,
.chat-row.me .chat-bubble.recalled .time {
  color: #6b7280;
}

.chat-recalled-text {
  font-size: 13px;
}

.chat-col {
  display: inline-block;
  vertical-align: top;
  max-width: 78%;
  /* avoid shrink-to-one-char with break-word + inline-block */
  min-width: 0;
  position: relative;
}

.chat-msg-actions {
  position: absolute;
  top: 50%;
  left: calc(100% + 6px);
  transform: translateY(-50%);
  margin: 0;
  line-height: 0;
  z-index: 2;
}

.chat-row.me .chat-msg-actions {
  left: calc(100% + 4px);
  right: auto;
  text-align: left;
}

.chat-recall {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(47, 127, 143, 0.22);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  color: #5b6b73;
  box-shadow: 0 1px 4px rgba(20, 40, 50, 0.08);
  cursor: pointer;
}

.chat-recall:hover,
.chat-recall:focus-visible {
  color: #c2410c;
  border-color: rgba(194, 65, 12, 0.35);
  background: #fff7ed;
  outline: none;
}

.chat-recall:disabled {
  opacity: 0.45;
  pointer-events: none;
}

.chat-recall-icon {
  display: block;
  pointer-events: none;
}


.chat-topbar .title {
  font-size: 14px;
  color: #333;
  font-weight: 600;
}

.chat-topbar .meta {
  font-size: 12px;
  color: #909399;
}

.chat-messages {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 78px;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 14px 12px 18px;
  -webkit-overflow-scrolling: touch;
}

.chat-row {
  overflow: visible;
  margin: 10px 0;
}

.chat-row:after {
  content: '';
  display: block;
  clear: both;
}

.chat-row.me {
  text-align: right;
}

.chat-avatar {
  --avatar-bg: #1f3a5f;
  --avatar-fg: #9ad1ff;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #1f3a5f;
  color: #9ad1ff;
  display: inline-block;
  vertical-align: top;
  line-height: 34px;
  text-align: center;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 1px;
  margin-right: 10px;
}

.chat-row.me .chat-avatar {
  margin-right: 0;
  margin-left: 34px;
}

.chat-bubble {
  display: inline-block;
  vertical-align: top;
  width: max-content;
  max-width: 100%;
  min-width: 52px;
  border-radius: 10px;
  padding: 8px 12px;
  border: 1px solid var(--chat-border);
  background: var(--chat-bubble-other);
  color: #333;
  position: relative;
  word-break: break-word;
  overflow-wrap: break-word;
  text-align: left;
  box-sizing: border-box;
}

.chat-row.me .chat-bubble {
  background: var(--chat-bubble-me);
  border-color: rgba(74, 144, 226, 0.5);
  color: #fff;
}

.chat-bubble .label {
  display: block;
  font-size: 11px;
  color: #909399;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  word-break: keep-all;
  line-height: 1.3;
}

.chat-row.me .chat-bubble .label {
  display: none;
}

.chat-bubble .time {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  line-height: 1.2;
  color: #a1a8b3;
  white-space: nowrap;
  text-align: right;
  opacity: 0.85;
  letter-spacing: 0;
}

.chat-row.me .chat-bubble .time {
  color: rgba(255, 255, 255, 0.78);
}

.chat-image-link {
  display: block;
  width: 400px;
  max-width: 100%;
  cursor: zoom-in;
}

.chat-image {
  display: block;
  width: 400px;
  max-width: 100%;
  height: 350px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: #fff;
}

.chat-image-caption {
  margin-top: 6px;
}

.chat-file-card {
  display: flex;
  align-items: center;
  gap: 12px;
  color: inherit;
}

.chat-file-icon {
  flex: 0 0 80px;
  width: 80px;
  height: 80px;
  border-radius: 12px;
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  border: 1px solid #93c5fd;
  color: #1d4ed8;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 800;
}

.chat-file-icon.pdf {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  border-color: #fca5a5;
  color: #b91c1c;
}

.chat-file-icon.zip {
  background: linear-gradient(135deg, #ffedd5, #fed7aa);
  border-color: #fdba74;
  color: #c2410c;
}

.chat-file-icon.sheet {
  background: linear-gradient(135deg, #dcfce7, #bbf7d0);
  border-color: #86efac;
  color: #15803d;
}

.chat-file-icon.doc {
  background: linear-gradient(135deg, #dbeafe, #bfdbfe);
  border-color: #93c5fd;
  color: #1d4ed8;
}

.chat-file-icon.ppt {
  background: linear-gradient(135deg, #ffedd5, #fdba74);
  border-color: #fb923c;
  color: #c2410c;
}

.chat-file-icon.audio {
  background: linear-gradient(135deg, #ede9fe, #ddd6fe);
  border-color: #c4b5fd;
  color: #6d28d9;
}

.chat-file-icon.video {
  background: linear-gradient(135deg, #fae8ff, #f5d0fe);
  border-color: #f0abfc;
  color: #a21caf;
}

.chat-file-icon.image {
  background: linear-gradient(135deg, #cffafe, #a5f3fc);
  border-color: #67e8f9;
  color: #0f766e;
}

.chat-file-icon.app {
  background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
  border-color: #a5b4fc;
  color: #4338ca;
}

.chat-video {
  display: block;
  width: 100%;
  max-width: 280px;
  max-height: 245px;
  border-radius: 10px;
  margin: 4px 0 8px;
  background: #000;
}

.chat-image-preview-wrap {
  position: relative;
  padding: 10px 54px;
  background: #000;
}

.chat-image-preview-nav {
  position: absolute;
  top: 50%;
  width: 36px;
  height: 36px;
  margin-top: -18px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 24px;
  line-height: 36px;
  text-align: center;
}

.chat-image-preview-nav.prev {
  left: 10px;
}

.chat-image-preview-nav.next {
  right: 10px;
}

.chat-file-meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.chat-file-name {
  font-size: 14px;
  color: inherit;
  word-break: break-all;
}

.chat-file-size {
  margin-top: 6px;
  font-size: 12px;
  color: #64748b;
}

.chat-image-preview-wrap {
  padding: 10px;
  background: #000;
}

.chat-image-preview {
  display: block;
  max-width: min(92vw, 1200px);
  max-height: 86vh;
}

.chat-composer {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 50;
  width: 100%;
  max-width: 1108px;
  margin-left: -554px;
  background: #fff;
  border-top: 1px solid var(--chat-border);
  padding: 10px 12px;
  box-shadow: 0 -4px 16px rgba(15, 23, 42, 0.06);
}

.chat-compose-row {
  overflow: hidden;
}

.chat-file-btn,
.chat-input,
.chat-btn {
  float: left;
}

.chat-file-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 1px solid #e4e7ed;
  background: #fff;
  color: #606266;
  text-align: center;
  padding: 0;
}

.chat-file-btn svg {
  margin-top: 8px;
}

.chat-input {
  width: 68%;
  height: 40px;
  margin: 0 10px;
  padding: 0 12px;
  border: 1px solid #e4e7ed;
  border-radius: 8px;
  background: #f5f7fa;
  outline: none;
}

.chat-input:focus {
  background: #fff;
  border-color: var(--color-primary);
}

.chat-btn {
  height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: 8px;
  background: var(--color-primary);
  color: #fff;
  font-weight: 500;
}

.chat-btn:disabled {
  opacity: 0.6;
}

.chat-file {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

label.chat-file-btn {
  cursor: pointer;
  box-sizing: border-box;
}

.chat-modal {
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 20000;
  text-align: center;
  padding: 16px;
}

.chat-modal[hidden] {
  display: none !important;
}

.chat-modal:before {
  content: '';
  display: inline-block;
  height: 100%;
  vertical-align: middle;
}

.chat-modal-backdrop {
  position: absolute;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  border: none;
  margin: 0;
  padding: 0;
  background: rgba(0, 0, 0, 0.45);
}

.chat-modal-box {
  position: relative;
  z-index: 1;
  display: inline-block;
  vertical-align: middle;
  width: 100%;
  max-width: 420px;
  text-align: left;
  background: #fff;
  border-radius: 10px;
  padding: 18px 18px 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
}

#chat-register-modal .chat-modal-box {
  position: fixed;
  left: 50%;
  top: 50%;
  display: block;
  width: 92%;
  max-width: 420px;
  margin: 0;
  transform: translate(-50%, -50%);
  -webkit-transform: translate(-50%, -50%);
}

.chat-modal-title {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
  color: #0f1111;
}

.chat-modal-desc {
  margin: 0 0 14px;
  font-size: 13px;
  color: #606266;
  line-height: 1.6;
}

.chat-form {
  overflow: hidden;
}

.chat-form input {
  display: block;
  width: 100%;
  height: 40px;
  border: 1px solid #e4e7ed;
  border-radius: 8px;
  padding: 0 12px;
  margin-bottom: 10px;
  outline: none;
  background: #f8fafc;
}

.chat-form input:focus {
  border-color: var(--color-primary);
  background: #fff;
}

.chat-form .err {
  font-size: 12px;
  color: #f56c6c;
  min-height: 16px;
}

.chat-form .actions {
  overflow: hidden;
  margin-top: 6px;
}

.chat-form .actions .chat-btn-outline,
.chat-form .actions .chat-btn-primary {
  float: right;
  margin-left: 10px;
}

.chat-btn-outline {
  height: 36px;
  padding: 0 16px;
  border-radius: 18px;
  border: 1px solid #d0d5dd;
  background: #fff;
  color: #333;
}

.chat-btn-primary {
  height: 36px;
  padding: 0 18px;
  border-radius: 18px;
  border: none;
  background: var(--color-primary);
  color: #fff;
  font-weight: 500;
}

@media (max-width: 1120px) {
  .chat-composer {
    left: 0;
    right: 0;
    width: auto;
    max-width: none;
    margin-left: 0;
  }
}

@media (max-width: 900px) {
  .rooms-hero {
    min-height: 240px;
    padding: 40px 28px;
  }

  .rooms-hero h1 {
    font-size: 36px;
    letter-spacing: 0.1em;
  }
}

@media (max-width: 768px) {
  .h5-header {
    position: fixed;
    left: 0;
    top: 0;
    right: 0;
  }

  .h5-header-inner {
    padding-left: 10px;
    padding-right: 10px;
  }

  body.chat-page {
    padding-bottom: 0;
  }

  .chat-shell {
    width: 100%;
    height: 100vh;
    min-height: 0;
    margin: 0;
    padding: 0;
  }

  .chat-topbar {
    padding: 8px 0;
  }

  .chat-topbar-room .title,
  .chat-topbar-room .meta {
    max-width: 170px;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .chat-topbar-back {
    margin-top: 2px;
  }

  .chat-messages {
    top: var(--header-h);
    bottom: 78px;
    min-height: 0;
    padding: 12px 10px 18px;
    box-sizing: border-box;
  }

  .chat-row {
    margin: 8px 0;
  }

  .chat-avatar {
    width: 32px;
    height: 32px;
    line-height: 32px;
    margin-right: 8px;
  }

  .chat-row.me .chat-avatar {
    margin-left: 30px;
  }

  .chat-col {
    max-width: min(78%, calc(100% - 48px));
  }

  .chat-bubble {
    width: max-content;
    max-width: 100%;
    font-size: 15px;
    padding: 8px 12px;
    border-radius: 14px;
  }

  .chat-bubble .label {
    font-size: 10px;
    margin-bottom: 2px;
    max-width: 12em;
  }

  .chat-bubble .time {
    font-size: 10px;
    margin-top: 2px;
  }

  .chat-image-link,
  .chat-image,
  .chat-video {
    width: 100%;
    max-width: 280px;
    height: 245px;
  }

  .chat-file-icon {
    flex-basis: 64px;
    width: 64px;
    height: 64px;
    font-size: 15px;
  }

  .chat-image-preview-wrap {
    padding: 10px 42px;
  }

  .chat-image-preview-nav {
    width: 30px;
    height: 30px;
    margin-top: -15px;
    font-size: 20px;
    line-height: 30px;
  }

  .chat-file-name {
    font-size: 13px;
  }

  .chat-composer {
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-width: none;
    margin-left: 0;
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .chat-compose-row {
    position: relative;
  }

  .chat-file-btn {
    width: 38px;
    height: 38px;
  }

  .chat-file-btn svg {
    margin-top: 7px;
  }

  .chat-input {
    width: calc(100% - 114px);
    margin: 0 8px;
    height: 38px;
  }

  .chat-btn {
    width: 60px;
    height: 38px;
    padding: 0;
  }
}

@media (max-width: 768px) {
  .rooms-shell {
    padding: 72px 14px 40px;
  }

  .rooms-hero {
    min-height: 220px;
    padding: 36px 22px 32px;
    border-radius: 22px;
    margin: 0 0 8px;
  }

  .rooms-hero-cta,
  .rooms-hero .chat-btn {
    width: auto;
    min-width: 132px;
    height: 42px;
    margin-top: 22px;
  }

  .rooms-hero h1 {
    font-size: 32px;
    letter-spacing: 0.1em;
  }

  .rooms-hero p {
    margin-top: 12px;
    font-size: 14px;
    line-height: 1.7;
  }

  .rooms-panel {
    margin-top: 28px;
    padding: 0;
    border-radius: 0;
  }

  .rooms-panel-head h2 {
    margin-top: 0;
    font-size: 18px;
  }

  .room-row {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 14px 14px;
  }

  .room-row-side {
    align-items: stretch;
  }

  .room-row-actions,
  .room-row-admin {
    justify-content: stretch;
  }

  .room-row-actions .chat-btn,
  .room-row-actions .chat-btn-outline,
  .room-row-admin .chat-btn-outline {
    flex: 1;
    text-align: center;
  }

  .room-row-name {
    white-space: normal;
  }

  .room-row-meta {
    flex-wrap: wrap;
    gap: 8px;
  }

  #room-create-modal,
  #room-qr-modal {
    padding: 0;
  }

  #room-create-modal:before,
  #room-qr-modal:before {
    display: none;
  }

  #room-create-modal .chat-modal-box,
  #room-qr-modal .chat-modal-box {
    position: fixed;
    left: 50%;
    top: 48%;
    display: block;
    width: 90%;
    max-width: none;
    max-height: 78vh;
    overflow: auto;
    margin: 0;
    padding: 16px 14px 14px;
    transform: translate(-50%, -50%);
    -webkit-transform: translate(-50%, -50%);
  }

  #room-create-modal .chat-modal-box {
    top: 43%;
    max-height: 68vh;
    padding-bottom: 18px;
  }

  #room-create-modal .chat-form {
    overflow: visible;
  }

  #room-create-modal .chat-form input {
    height: 42px;
    font-size: 16px;
    margin-bottom: 12px;
  }

  #room-create-modal .chat-modal-desc {
    margin-bottom: 12px;
  }

  #room-create-modal .chat-form .err {
    min-height: 18px;
    margin-bottom: 4px;
  }

  #room-create-modal .chat-form .actions,
  #room-qr-modal .actions {
    overflow: visible;
    margin-top: 12px;
  }

  #room-create-modal .chat-form .actions .chat-btn-outline,
  #room-create-modal .chat-form .actions .chat-btn-primary,
  #room-qr-modal .actions .chat-btn-outline,
  #room-qr-modal .actions .chat-btn-primary {
    float: none;
    display: block;
    width: 100%;
    height: 40px;
    line-height: 40px;
    text-align: center;
    margin: 0 0 10px;
    border-radius: 12px;
  }

  #room-create-modal .chat-form .actions .chat-btn-primary,
  #room-qr-modal .actions .chat-btn-outline:last-child {
    margin-bottom: 0;
  }

  .room-qr-box {
    max-width: none;
  }

  .room-qr-image {
    width: 210px;
    height: 210px;
  }

  .chat-topbar-home .title {
    font-size: 18px;
    line-height: 1.2;
    letter-spacing: 0.06em;
  }
}

@media (max-width: 640px) {
  #chat-register-modal {
    padding: 0;
  }

  #chat-register-modal:before {
    display: none;
  }

  #chat-register-modal .chat-modal-box {
    width: 90%;
    max-width: none;
    left: 50%;
    top: 46%;
    transform: translate(-50%, -50%);
    -webkit-transform: translate(-50%, -50%);
  }

  .chat-topbar-clear,
  .chat-topbar-back,
  #admin-entry {
    height: 30px;
    line-height: 28px;
    padding: 0 10px;
    font-size: 12px;
  }

  .chat-topbar-room > div:first-child,
  .chat-topbar-home > div:first-child {
    max-width: calc(100% - 150px);
  }
}


/* ===== Chat room page: clean ink UI ===== */
body.chat-room-page {
  background:
    radial-gradient(ellipse 70% 48% at 88% -6%, rgba(47, 127, 143, 0.13), transparent 56%),
    radial-gradient(ellipse 55% 40% at 6% 100%, rgba(90, 110, 100, 0.08), transparent 52%),
    linear-gradient(180deg, #e4ecec 0%, #eef2f1 48%, #e6ebe9 100%);
}

body.chat-room-page .chat-room-header {
  background: rgba(250, 252, 252, 0.9);
  border-bottom: 1px solid rgba(160, 180, 178, 0.38);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

body.chat-room-page .chat-cs-name {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #1a2f32;
}

body.chat-room-page .chat-topbar-clear {
  height: 32px;
  line-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
}

body.chat-room-page .chat-shell {
  max-width: 860px;
}

body.chat-room-page .chat-messages {
  bottom: 72px;
  padding: 16px 14px 20px;
}

body.chat-room-page .chat-row {
  margin: 12px 0;
}

body.chat-room-page .chat-avatar {
  width: 32px;
  height: 32px;
  line-height: 32px;
  font-size: 13px;
  font-weight: 700;
  border-radius: 10px;
  margin-right: 8px;
}

body.chat-room-page .chat-row.me .chat-avatar {
  margin-left: 34px;
}

body.chat-room-page .chat-col {
  max-width: 78%;
  min-width: 0;
}

body.chat-room-page .chat-bubble {
  width: max-content;
  max-width: 100%;
  border-radius: 16px;
  padding: 9px 12px 7px;
  border: 1px solid rgba(160, 180, 178, 0.4);
  background: rgba(255, 255, 255, 0.94);
  color: #1a2f32;
  box-shadow: none;
  overflow-wrap: break-word;
}

body.chat-room-page .chat-row.me .chat-bubble {
  background: linear-gradient(145deg, #2a7382, #3a91a0);
  border-color: transparent;
  color: #fff;
}

body.chat-room-page .chat-bubble .label {
  margin-bottom: 2px;
  font-size: 10px;
  letter-spacing: 0.02em;
  color: #7b90a6;
}

body.chat-room-page .chat-row.me .chat-bubble .label {
  display: none;
}

body.chat-room-page .chat-bubble .time {
  margin-top: 3px;
  font-size: 10px;
  color: #94a3b8;
}

body.chat-room-page .chat-row.me .chat-bubble .time {
  color: rgba(255, 255, 255, 0.72);
}

body.chat-room-page .chat-image,
body.chat-room-page .chat-image-link {
  width: 100%;
  max-width: 260px;
  height: auto;
  max-height: 220px;
  border-radius: 12px;
}

body.chat-room-page .chat-composer {
  left: 50%;
  max-width: 860px;
  margin-left: -430px;
  background: rgba(255, 255, 255, 0.92);
  border-top: 1px solid rgba(180, 202, 220, 0.42);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 24px rgba(16, 42, 72, 0.05);
}

body.chat-room-page .chat-compose-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: visible;
}

body.chat-room-page .chat-file-btn,
body.chat-room-page .chat-input,
body.chat-room-page .chat-btn {
  float: none;
}

body.chat-room-page .chat-file-btn {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid rgba(178, 200, 220, 0.55);
  background: #fff;
  color: #4a657e;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.chat-room-page .chat-file-btn svg {
  margin-top: 0;
}

body.chat-room-page .chat-input {
  flex: 1;
  width: auto;
  min-width: 0;
  height: 40px;
  margin: 0;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid rgba(160, 180, 178, 0.5);
  background: #f3f7f6;
}

body.chat-room-page .chat-input:focus {
  background: #fff;
  border-color: #3a91a0;
}

body.chat-room-page .chat-btn {
  flex: 0 0 auto;
  min-width: 68px;
  height: 40px;
  padding: 0 16px;
  border-radius: 12px;
  background: #2f7f8f;
  font-weight: 600;
}

body.chat-room-page .chat-recall {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(47, 127, 143, 0.2);
  background: rgba(255, 255, 255, 0.95);
  color: #5b6b73;
  box-shadow: 0 1px 4px rgba(20, 40, 50, 0.08);
}

body.chat-room-page .chat-modal-box {
  border-radius: 18px;
  padding: 22px 20px 18px;
  border: 1px solid rgba(178, 200, 220, 0.45);
  box-shadow: 0 24px 48px rgba(16, 42, 72, 0.16);
}

body.chat-room-page .chat-modal-title {
  font-size: 20px;
  color: #13293f;
  letter-spacing: 0.04em;
}

body.chat-room-page .chat-modal-desc {
  color: #6d859c;
}

@media (max-width: 1120px) {
  body.chat-room-page .chat-composer {
    left: 0;
    right: 0;
    margin-left: 0;
    max-width: none;
  }
}

@media (max-width: 768px) {
  body.chat-room-page .chat-messages {
    top: var(--header-h);
    bottom: 72px;
    padding: 12px 10px 16px;
  }

  body.chat-room-page .chat-col {
    max-width: 78%;
  }

  body.chat-room-page .chat-composer {
    padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  }

  body.chat-room-page .chat-btn {
    min-width: 58px;
    padding: 0 12px;
  }
}


body.chat-room-page .chat-image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 30000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 48px;
  background: rgba(8, 18, 32, 0.88);
}

body.chat-room-page .chat-image-lightbox[hidden] {
  display: none !important;
}

body.chat-room-page .chat-image-lightbox .chat-image-preview {
  max-width: min(92vw, 1100px);
  max-height: 86vh;
  width: auto;
  height: auto;
  border-radius: 8px;
}

body.chat-room-page .chat-image-lightbox-close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 26px;
  line-height: 40px;
}

body.chat-room-page .chat-image-lightbox .chat-image-preview-nav {
  position: absolute;
  top: 50%;
  margin-top: -20px;
}

body.chat-room-page .chat-image-lightbox .chat-image-preview-nav.prev {
  left: 12px;
}

body.chat-room-page .chat-image-lightbox .chat-image-preview-nav.next {
  right: 12px;
}


.rooms-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
  align-items: center;
}

.rooms-hero-actions .rooms-hero-cta {
  margin-top: 0;
}

.rooms-hero-cta-alt {
  height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}

.rooms-hero-cta-alt:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* 客服访客开场公告 */
.chat-announce {
  margin: 8px 8px 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: linear-gradient(180deg, #f3faf9 0%, #eef6f5 100%);
  border: 1px solid rgba(58, 145, 160, 0.28);
  color: #1a2f32;
  box-shadow: 0 4px 14px rgba(26, 90, 102, 0.06);
}
.chat-announce-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #2a7382;
  margin-bottom: 6px;
}
.chat-announce-body {
  font-size: 14px;
  line-height: 1.55;
  white-space: normal;
  word-break: break-word;
}
.chat-announce-body p {
  margin: 0 0 0.4em;
}
.chat-announce-body p:last-child {
  margin-bottom: 0;
}
.chat-announce-body ul,
.chat-announce-body ol {
  margin: 0.25em 0 0.25em 1.2em;
  padding: 0;
}
.chat-announce-body a {
  color: #2a7382;
  text-decoration: underline;
}

#room-announce {
  width: 100%;
  box-sizing: border-box;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid #e4e7ed;
  border-radius: 8px;
  font: inherit;
  resize: vertical;
  min-height: 72px;
  background: #f5f7fa;
}
#room-announce[hidden] { display: none !important; }
