/* H5 访客端 — 清爽玻璃拟态 */
:root {
  --bg0: #e0f2fe;
  --bg1: #f0f9ff;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-solid: #ffffff;
  --primary: #0284c7;
  --primary-dark: #0369a1;
  --primary-glow: rgba(14, 165, 233, 0.25);
  --text: #0c4a6e;
  --muted: #64748b;
  --line: rgba(14, 165, 233, 0.18);
  --bubble-me: linear-gradient(145deg, #0ea5e9 0%, #0284c7 100%);
  --bubble-them: #ffffff;
  --radius: 18px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

html { height: 100%; }
body.h5-body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg1);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(14, 165, 233, 0.35), transparent 55%),
    radial-gradient(ellipse 80% 50% at 100% 50%, rgba(56, 189, 248, 0.12), transparent 50%),
    linear-gradient(180deg, var(--bg0) 0%, var(--bg1) 45%, #f8fafc 100%);
  display: flex;
  flex-direction: column;
  -webkit-tap-highlight-color: transparent;
}

.h5-app {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}

/* 顶栏 */
.h5-header {
  flex-shrink: 0;
  padding: calc(12px + env(safe-area-inset-top)) 18px 14px;
  background: var(--surface);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 4px 24px rgba(14, 165, 233, 0.06);
}

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

.h5-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.h5-logo {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 6px 20px rgba(50, 200, 218, 0.28);
  background: rgba(255, 255, 255, 0.9);
}

.h5-logo .h5-logo-svg {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.h5-title-wrap { min-width: 0; }
.h5-title-wrap h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.25;
}

.h5-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  margin-top: 4px;
}

.h5-status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
  animation: pulse 2s ease-in-out infinite;
}

.h5-status.closed .dot {
  background: var(--muted);
  box-shadow: none;
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

.h5-guest-pill {
  flex-shrink: 0;
  max-width: 42%;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-dark);
  background: rgba(14, 165, 233, 0.1);
  border: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 主区域 */
.h5-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 14px 8px;
}

.welcome-banner {
  flex-shrink: 0;
  font-size: 13px;
  line-height: 1.55;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  box-shadow: 0 2px 12px rgba(14, 165, 233, 0.05);
}

.h5-chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 8px 4px 16px;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}

/* 气泡 */
.bubble {
  max-width: 88%;
  margin-bottom: 12px;
  padding: 11px 14px;
  border-radius: 18px;
  animation: pop 0.25s ease;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.bubble .meta {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 5px;
  font-weight: 500;
}

.bubble .text {
  font-size: 15px;
  line-height: 1.55;
  word-break: break-word;
}

.bubble.out {
  margin-left: auto;
  background: var(--bubble-me);
  color: #fff;
  border-radius: 18px 18px 6px 18px;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.bubble.out .meta {
  color: rgba(255, 255, 255, 0.85);
}

.bubble.in {
  margin-right: auto;
  background: var(--bubble-them);
  border: 1px solid var(--line);
  border-radius: 18px 18px 18px 6px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
}

.bubble.in .meta {
  color: var(--muted);
}

/* 底栏输入 */
.h5-footer {
  flex-shrink: 0;
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--surface);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 24px rgba(14, 165, 233, 0.06);
}

.h5-footer.closed {
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.h5-footer.closed p { margin: 0; padding: 8px; }

.h5-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.h5-form textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 16px;
  font-family: inherit;
  resize: none;
  color: var(--text);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

.h5-form textarea:focus {
  outline: none;
  border-color: rgba(14, 165, 233, 0.55);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.send-btn {
  flex-shrink: 0;
  min-width: 72px;
  padding: 12px 18px;
  border: none;
  border-radius: 16px;
  background: var(--bubble-me);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px var(--primary-glow);
}

.send-btn:active:not(:disabled) {
  transform: scale(0.97);
  filter: brightness(0.95);
}

.send-btn:disabled {
  opacity: 0.75;
  cursor: not-allowed;
  transform: none;
}

/* 空状态 */
.h5-empty {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 14px;
}
