:root {
  color-scheme: dark;
  --bg: #06141c;
  --panel: #0f2432;
  --text: #f3fbff;
  --muted: #9cc0d9;
  --primary: #4ade80;
  --primary-2: #23c55e;
  --border: rgba(176, 220, 255, 0.14);
  --danger: #fb7185;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  overflow-x: hidden;
  background:
    radial-gradient(circle at top right, rgba(35, 197, 94, 0.16), transparent 22rem),
    linear-gradient(180deg, #0a1c27 0%, #08141c 100%);
  color: var(--text);
  font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

.shell { width: min(2240px, calc(100vw - 20px)); margin: 0 auto; padding: 24px 0 56px; }
.shell.narrow { width: min(860px, calc(100% - 32px)); }
.home-wide-layout {
  width: min(2320px, calc(100vw - 20px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr) 180px;
  gap: 16px;
  align-items: start;
}
.home-shell {
  width: 100%;
  margin: 0;
  padding: 24px 0 56px;
}
.home-ad-rail {
  padding-top: 108px;
}
.home-ad-rail--left {
  justify-self: end;
}
.home-ad-rail--right {
  justify-self: start;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 28px;
}

.brand { font-size: 24px; font-weight: 800; letter-spacing: 0.02em; }
.topnav { display: flex; align-items: center; gap: 12px; color: var(--muted); }
.top-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
}

.wallet-badge-wrap {
  display: grid;
  gap: 4px;
  justify-items: end;
}

.wallet-badge-label {
  color: var(--muted);
  font-size: 12px;
}

.wallet-badge {
  min-width: 220px;
  max-width: 360px;
  padding: 10px 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wallet-badge.connected {
  border-color: rgba(74, 222, 128, 0.28);
  color: #dfffe9;
  background: rgba(74, 222, 128, 0.08);
}

.topnav a, .link-button {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
  cursor: pointer;
}

.hero-grid, .dashboard-columns { display: grid; grid-template-columns: minmax(0, 0.94fr) minmax(0, 1.06fr); gap: 20px; }
.dashboard-columns { align-items: start; }
.dashboard-columns--template { grid-template-columns: 1fr; }
.dashboard-columns--chat { grid-template-columns: minmax(0, 1.42fr) minmax(320px, 0.78fr); }
.stack { display: grid; gap: 20px; }

.panel, .hero-card {
  background: linear-gradient(180deg, rgba(18, 42, 59, 0.98), rgba(9, 26, 37, 0.98));
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.panel-gated {
  opacity: 0.58;
}

.hero-panel { padding-top: 32px; }

.pill, .tag {
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(74, 222, 128, 0.12);
  color: #c7ffd8;
  border: 1px solid rgba(74, 222, 128, 0.28);
  font-size: 12px;
  font-weight: 700;
}

h1, h2, h3 { margin: 0; }
h1 { font-size: clamp(34px, 4vw, 52px); line-height: 1.08; margin-top: 16px; }
h2 { font-size: 24px; }
h3 { font-size: 20px; }

.lede, .panel p, .muted, .note { color: var(--muted); line-height: 1.7; }

.cta-row, .button-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 20px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid transparent;
  cursor: pointer;
  font-weight: 700;
}

.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #072114; }
.btn-secondary { background: rgba(255, 255, 255, 0.05); border-color: var(--border); color: var(--text); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-danger { background: rgba(251, 113, 133, 0.1); border-color: rgba(251, 113, 133, 0.3); color: #ffd5dc; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.is-disabled { opacity: 0.55; cursor: not-allowed; }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }

.site-footer {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  display: grid;
  gap: 10px;
}

.site-footer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.footer-links a {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
}

.legal-shell {
  width: min(980px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.legal-hero {
  display: grid;
  gap: 16px;
  margin-bottom: 20px;
}

.legal-title {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.1;
}

.legal-meta {
  color: var(--muted);
  font-size: 14px;
}

.legal-content {
  display: grid;
  gap: 18px;
}

.legal-section {
  background: linear-gradient(180deg, rgba(18, 42, 59, 0.98), rgba(9, 26, 37, 0.98));
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow);
}

.legal-section h2 {
  margin-bottom: 12px;
}

.legal-section p,
.legal-section li {
  color: var(--muted);
  line-height: 1.8;
}

.legal-section ul {
  margin: 0;
  padding-left: 20px;
}

.template-grid, .feature-grid, .info-grid { display: grid; gap: 14px; }
.template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.feature-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); align-items: stretch; }
.info-grid { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.template-card, .feature-card, .info-item, .status-box, .list-box, .chat-box, .code-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.template-card, .info-item { padding: 16px; }
.feature-card { padding: 11px 13px; min-height: 92px; }
.feature-card h3 { font-size: 15px; margin-bottom: 6px; }
.feature-card p { font-size: 13px; line-height: 1.55; margin: 0; }
.feature-panel-home {
  padding: 12px 16px;
}
.feature-panel-home__head {
  display: none;
}
.feature-panel-home .feature-grid {
  gap: 10px;
}
.feature-panel-home .feature-card {
  padding: 8px 10px;
  min-height: 52px;
  border-radius: 16px;
}
.feature-panel-home .feature-card h3 {
  font-size: 14px;
  margin-bottom: 4px;
}
.feature-panel-home .feature-card p {
  font-size: 12px;
  line-height: 1.38;
}
.info-item span { display: block; margin-bottom: 8px; color: var(--muted); font-size: 13px; }
.info-item strong { font-size: 16px; line-height: 1.5; word-break: break-word; }
.info-item-action { display: grid; gap: 10px; }
.info-item-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.info-item-label-row span { margin-bottom: 0; }
.info-item-note {
  display: block;
  font-size: 12px;
  line-height: 1.6;
}
.inline-action {
  min-height: 32px;
  padding: 6px 12px;
  font-size: 12px;
}
.status-box { margin-top: 16px; padding: 14px 16px; color: #d7efff; }
.hero-meta-box {
  display: grid;
  grid-template-columns: minmax(260px, 0.84fr) minmax(0, 1.16fr);
  gap: 16px;
  align-items: start;
}
.hero-meta-item {
  line-height: 1.65;
}
.hero-meta-item span {
  color: var(--text);
  word-break: break-all;
}
.hero-meta-item--secondary {
  color: var(--muted);
}
#home-support-box,
#home-health,
#home-ad-slot-note {
  display: none !important;
}
.panel-head:has(+ .feature-grid) .muted {
  display: none;
}
.dashboard-status-inline {
  margin-top: 14px;
  min-height: 20px;
  color: var(--muted);
  line-height: 1.6;
}
.mini-status { margin-top: 20px; color: var(--muted); }
.hero-ad-note {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.template-purchase-note {
  margin-top: 16px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.7;
}

.template-card {
  display: grid;
  align-content: start;
  gap: 12px;
  min-height: 0;
}

.template-card h3 {
  font-size: 18px;
}

.template-card p {
  margin: 0;
  font-size: 13px;
  line-height: 1.65;
}

.template-buy-btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 13px;
  white-space: nowrap;
  justify-self: start;
}

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.form-grid label, .inline-form { display: grid; gap: 8px; }
.form-grid label span { color: var(--muted); }

input, select, textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  padding: 13px 14px;
}

.form-actions { align-items: end; }
.code-box {
  width: 100%;
  min-height: 180px;
  margin-top: 16px;
  padding: 16px;
  resize: vertical;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 13px;
}

.compact-box {
  min-height: 120px;
}

.list-box {
  min-height: 72px;
  padding: 14px;
  display: grid;
  gap: 10px;
}

.list-item {
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.04);
}

.list-item .meta { margin-top: 6px; color: var(--muted); font-size: 13px; line-height: 1.6; }

.chat-box {
  min-height: 320px;
  max-height: 420px;
  padding: 16px;
  overflow: auto;
  display: grid;
  gap: 10px;
}

.chat-message {
  display: inline-grid;
  gap: 6px;
  max-width: 92%;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
}

.chat-message.self { justify-self: end; background: rgba(74, 222, 128, 0.12); }
.chat-meta { font-size: 12px; color: var(--muted); }
.chat-form { display: grid; gap: 12px; margin-top: 14px; }

.log-box {
  min-height: 200px;
  max-height: 320px;
  overflow: auto;
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: 12px;
}

.log-item {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  color: #d7efff;
  line-height: 1.6;
}

.log-item.error {
  background: rgba(251,113,133,0.12);
  color: #ffd5dc;
}

.result-panel {
  padding-top: 32px;
}

.result-panel.success {
  border-color: rgba(74, 222, 128, 0.3);
}

.result-panel.failed {
  border-color: rgba(251, 113, 133, 0.3);
}

.merchant-intro {
  margin: 0 0 18px;
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.qr-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
}

.qr-card-head {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
}

.qr-preview-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 240px;
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--border);
}

.qr-preview {
  width: min(100%, 220px);
  height: auto;
  border-radius: 16px;
  background: #f7fbff;
  padding: 10px;
}

.ad-slot-strip {
  width: 100%;
  margin: 10px 0 0;
  padding: 0 0 18px;
}

.ad-slot-strip-head {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.ad-slot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: 10px;
  align-items: stretch;
  justify-content: stretch;
}
.ad-slot-grid--rail {
  grid-template-columns: 1fr;
  min-width: 170px;
  gap: 8px;
}

.ad-slot-grid--rail .ad-slot-card {
  min-height: 58px;
  padding: 4px 6px;
}

.ad-slot-grid--rail .ad-slot-plus {
  font-size: 22px;
}

.ad-slot-grid--rail .ad-slot-price {
  font-size: 10px;
}

.ad-slot-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 64px;
  padding: 6px 6px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-align: center;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
  overflow: hidden;
}

.ad-slot-card:hover {
  transform: translateY(-2px);
  border-color: rgba(74, 222, 128, 0.32);
}

.ad-slot-card.available {
  cursor: pointer;
  background: rgba(255, 255, 255, 0.02);
}

.ad-slot-card.available:hover {
  background: rgba(74, 222, 128, 0.08);
}

.ad-slot-card.pending {
  cursor: default;
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.22);
}

.ad-slot-card.active {
  cursor: pointer;
}

.ad-slot-card.active:not([href]) {
  cursor: default;
}

.ad-slot-plus {
  font-size: 24px;
  line-height: 1;
  font-weight: 700;
  color: #d7efff;
}

.ad-slot-caption,
.ad-slot-pending {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.2;
}

.ad-slot-pending {
  color: #ffe7a0;
  font-weight: 700;
}

.ad-slot-label {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.15;
  word-break: break-word;
}

.ad-slot-caption {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ad-slot-thumb {
  width: 100%;
  height: 40px;
  object-fit: cover;
  border-radius: 10px;
  display: block;
}

.ad-slot-loading {
  grid-column: 1 / -1;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  border: 1px dashed var(--border);
  color: var(--muted);
}

.ad-slot-type-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}

.ad-slot-form-grid {
  display: grid;
  gap: 14px;
}

.ad-slot-form-grid label {
  display: grid;
  gap: 8px;
}

.ad-slot-preview {
  margin-top: 14px;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.ad-slot-preview-image {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 12px;
  display: block;
}

.hidden {
  display: none !important;
}

.wallet-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
}

.wallet-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 13, 18, 0.72);
  backdrop-filter: blur(8px);
}

.wallet-modal-card {
  position: relative;
  width: min(520px, calc(100% - 32px));
  margin: 10vh auto 0;
  padding: 24px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(18, 42, 59, 0.99), rgba(9, 26, 37, 0.99));
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.wallet-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 40;
  min-width: 74px;
  min-height: 74px;
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 12px;
  border-radius: 24px;
  border: 1px solid rgba(74, 222, 128, 0.28);
  background: linear-gradient(180deg, rgba(18, 42, 59, 0.98), rgba(9, 26, 37, 0.98));
  color: var(--text);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.32);
}

.chat-launcher:hover {
  transform: translateY(-2px);
  border-color: rgba(74, 222, 128, 0.42);
}

.chat-launcher-icon {
  font-size: 22px;
  line-height: 1;
}

.chat-launcher-label {
  font-size: 12px;
  color: var(--muted);
}

.chat-backdrop {
  position: fixed;
  inset: 0;
  z-index: 41;
  background: rgba(3, 10, 15, 0.46);
  backdrop-filter: blur(3px);
}

.chat-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 42;
  width: min(460px, calc(100vw - 24px));
  height: 100vh;
  transform: translateX(108%);
  transition: transform 0.22s ease;
  background: linear-gradient(180deg, rgba(13, 32, 45, 0.99), rgba(8, 21, 30, 0.99));
  border-left: 1px solid var(--border);
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.26);
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 14px;
  padding: 20px 18px 18px;
}

.chat-drawer.open {
  transform: translateX(0);
}

.chat-drawer-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.chat-drawer-header h2 {
  font-size: 26px;
}

.chat-drawer-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.chat-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.chat-switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.chat-language-select,
.chat-search-input,
.chat-composer-input {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.chat-language-select {
  min-height: 42px;
  min-width: 146px;
  padding: 0 12px;
  border-radius: 14px;
}

.chat-search-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.chat-search-input {
  min-height: 44px;
  padding: 0 14px;
  border-radius: 14px;
}

.chat-search-result {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.chat-search-hit {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-sections {
  min-height: 0;
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 14px;
}

.chat-side-panel,
.chat-main-panel {
  min-height: 0;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 18px;
  padding: 14px;
}

.chat-side-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 120px) auto minmax(0, 1fr);
  gap: 10px;
}

.chat-main-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
}

.chat-section-head,
.chat-thread-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.chat-section-head-gap {
  margin-top: 6px;
}

.chat-request-list,
.chat-friend-list,
.chat-message-list {
  min-height: 0;
  overflow: auto;
}

.chat-request-list,
.chat-friend-list {
  display: grid;
  gap: 10px;
}

.chat-mini-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.chat-mini-btn {
  min-height: 38px;
  padding: 0 12px;
}

.chat-friend-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.chat-friend-item.active {
  border-color: rgba(74, 222, 128, 0.35);
  background: rgba(74, 222, 128, 0.08);
}

.chat-friend-main {
  display: grid;
  gap: 3px;
}

.chat-online-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: rgba(156, 192, 217, 0.3);
  flex: 0 0 auto;
}

.chat-online-dot.online {
  background: #4ade80;
  box-shadow: 0 0 0 6px rgba(74, 222, 128, 0.12);
}

.chat-presence-badge {
  min-width: 58px;
  text-align: center;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(251, 113, 133, 0.28);
  background: rgba(251, 113, 133, 0.08);
  color: #ffd5dc;
  font-size: 12px;
  font-weight: 700;
}

.chat-presence-badge.online {
  border-color: rgba(74, 222, 128, 0.28);
  background: rgba(74, 222, 128, 0.1);
  color: #dfffe9;
}

.chat-message-list {
  display: grid;
  gap: 12px;
  align-content: start;
  padding-right: 4px;
}

.chat-bubble-row {
  display: flex;
}

.chat-bubble-row.self {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: 82%;
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
}

.chat-bubble.self {
  border-color: rgba(74, 222, 128, 0.26);
  background: rgba(74, 222, 128, 0.08);
}

.chat-bubble-content {
  line-height: 1.65;
  word-break: break-word;
}

.chat-bubble-translation {
  padding-top: 8px;
  border-top: 1px dashed rgba(176, 220, 255, 0.16);
  color: var(--muted);
  line-height: 1.6;
}

.chat-bubble-meta {
  font-size: 11px;
  color: var(--muted);
}

.chat-composer {
  display: grid;
  gap: 10px;
}

.chat-composer-input {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  padding: 12px 14px;
  border-radius: 16px;
}

.chat-composer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-empty {
  padding: 14px;
  border-radius: 14px;
  border: 1px dashed var(--border);
  color: var(--muted);
  text-align: center;
  line-height: 1.6;
}

.chat-empty-large {
  min-height: 160px;
  display: grid;
  place-items: center;
}

@media (max-width: 1800px) {
  .ad-slot-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
}

@media (max-width: 1400px) {
  .ad-slot-grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); }
}

@media (max-width: 900px) {
  .home-wide-layout { grid-template-columns: 1fr; width: min(100vw, calc(100vw - 20px)); }
  .home-ad-rail { display: none; }
  .home-shell { width: min(2240px, calc(100vw - 20px)); margin: 0 auto; }
  .hero-grid, .dashboard-columns { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
  .top-actions { width: 100%; justify-content: space-between; margin-left: 0; }
  .wallet-badge-wrap { justify-items: start; }
  .wallet-badge { max-width: none; width: min(100%, 320px); }
  .wallet-modal-card { margin-top: 8vh; }
  .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-meta-box { grid-template-columns: 1fr; gap: 10px; }
  .template-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ad-slot-strip { width: auto; margin-left: 0; margin-right: 0; padding: 0 0 16px; }
  .ad-slot-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
  .chat-box--large { min-height: 420px; max-height: 560px; }
  .friend-list-box { min-height: 240px; max-height: 360px; }
  .chat-drawer {
    width: min(100vw, 100vw);
  }
  .chat-sections {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
  }
  .chat-side-panel {
    grid-template-rows: auto minmax(0, 140px) auto minmax(0, 180px);
  }
}

@media (max-width: 640px) {
  .feature-grid { grid-template-columns: 1fr; }
  .template-grid { grid-template-columns: 1fr; }
  .ad-slot-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .ad-slot-card { min-height: 64px; }
  .chat-launcher {
    right: 14px;
    bottom: 14px;
    min-width: 62px;
    min-height: 62px;
    border-radius: 20px;
  }
  .chat-launcher-label {
    display: none;
  }
  .chat-drawer {
    width: 100vw;
    padding: 14px;
    gap: 12px;
  }
  .chat-toolbar,
  .chat-search-form,
  .chat-composer-row {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: stretch;
  }
  .chat-search-form {
    display: grid;
  }
  .chat-search-hit,
  .chat-thread-head,
  .chat-drawer-header {
    align-items: stretch;
    flex-direction: column;
  }
  .chat-bubble {
    max-width: 100%;
  }
}

/* QQ-style chat refresh */
.chat-drawer {
  width: min(620px, calc(100vw - 18px));
  padding: 16px;
  gap: 12px;
}

.chat-drawer-header--qq {
  align-items: center;
  padding-bottom: 4px;
}

.chat-drawer-header--qq h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.chat-header-copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.chat-toolbar--qq {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(7, 25, 41, 0.92);
  border: 1px solid rgba(126, 205, 255, 0.12);
}

.chat-search-form--compact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin: 0;
}

.chat-search-input--compact {
  min-width: 0;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(126, 205, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #f4fbff;
  font-size: 14px;
}

.chat-search-submit--compact {
  height: 40px;
  padding: 0 16px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #2fe57d, #1fc0ff);
  color: #042033;
  font-weight: 800;
  cursor: pointer;
}

.chat-switch--compact {
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(126, 205, 255, 0.12);
  white-space: nowrap;
}

.chat-language-select--compact {
  min-width: 160px;
  height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(126, 205, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #f4fbff;
  font-size: 14px;
}

.status-box--compact {
  margin: 0;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
}

.chat-search-result--compact {
  margin: 0;
  padding: 8px 14px;
  border-radius: 14px;
  font-size: 13px;
}

.chat-sections--qq {
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 12px;
}

.chat-side-panel--qq,
.chat-main-panel--qq {
  background: rgba(10, 30, 48, 0.82);
  border: 1px solid rgba(126, 205, 255, 0.12);
  border-radius: 18px;
}

.chat-side-panel--qq {
  padding: 14px;
  gap: 10px;
}

.chat-main-panel--qq {
  padding: 14px;
  gap: 12px;
}

.chat-empty--qq {
  border-radius: 14px;
  font-size: 13px;
}

.chat-thread-head {
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(126, 205, 255, 0.12);
}

.chat-message-list {
  min-height: 320px;
  max-height: min(52vh, 560px);
  padding: 8px 2px 8px 0;
}

.chat-composer {
  padding-top: 10px;
  border-top: 1px solid rgba(126, 205, 255, 0.12);
}

.chat-composer-input {
  min-height: 92px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

@media (max-width: 960px) {
  .chat-drawer {
    width: min(100vw - 12px, 100vw);
    right: 6px;
    left: 6px;
    bottom: 6px;
    top: auto;
    max-height: calc(100vh - 12px);
  }

  .chat-toolbar--qq {
    grid-template-columns: 1fr;
  }

  .chat-language-select--compact {
    min-width: 0;
    width: 100%;
  }

  .chat-sections--qq {
    grid-template-columns: 1fr;
  }

  .chat-message-list {
    min-height: 240px;
  }
}

/* QQ-like simplified chat pass */
.chat-drawer {
  width: min(980px, calc(100vw - 18px));
  padding: 14px;
  gap: 10px;
}

.chat-drawer-header--qq {
  padding: 2px 2px 4px;
}

.chat-drawer-header--qq h2 {
  font-size: 20px;
}

.chat-toolbar--qq {
  gap: 8px;
  padding: 8px 10px;
}

.chat-search-input--compact,
.chat-search-submit--compact,
.chat-switch--compact,
.chat-language-select--compact {
  height: 36px;
  font-size: 13px;
}

.chat-search-input--compact {
  padding: 0 12px;
}

.chat-search-submit--compact,
.chat-switch--compact {
  padding: 0 12px;
}

.chat-language-select--compact {
  min-width: 148px;
  padding: 0 12px;
}

.chat-sections--qq {
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 12px;
}

.chat-side-panel--qq,
.chat-main-panel--qq {
  border-radius: 16px;
}

.chat-side-panel--qq {
  padding: 12px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 840px;
}

.chat-main-panel--qq {
  padding: 12px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-height: 840px;
}

.chat-panel-block__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.chat-panel-block__head strong {
  font-size: 13px;
  color: #f4fbff;
}

.chat-panel-block__head span {
  font-size: 12px;
  color: #89b7d4;
}

.chat-placeholder {
  color: #89b7d4;
  font-size: 13px;
  line-height: 1.5;
  padding: 10px 6px;
}

.chat-side-item {
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(126, 205, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #f4fbff;
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  cursor: pointer;
}

.chat-side-item.is-active {
  border-color: rgba(47, 229, 125, 0.5);
  background: rgba(47, 229, 125, 0.12);
}

.chat-side-item__title {
  font-size: 13px;
  font-weight: 700;
}

.chat-side-item__meta {
  font-size: 12px;
  color: #89b7d4;
}

.chat-search-result-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.chat-search-result-card__title {
  font-size: 13px;
  font-weight: 700;
  color: #f4fbff;
}

.chat-search-result-card__meta {
  margin-top: 2px;
  font-size: 12px;
  color: #89b7d4;
}

.chat-thread-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
}

.chat-thread-head__title {
  font-size: 17px;
  font-weight: 800;
  color: #f4fbff;
}

.chat-thread-head__meta {
  margin-top: 2px;
  font-size: 12px;
  color: #89b7d4;
}

.chat-thread-head__presence {
  font-size: 12px;
  color: #2fe57d;
  white-space: nowrap;
}

.chat-friend-list {
  min-height: 720px;
  max-height: min(80vh, 980px);
}

.chat-message-list {
  min-height: 720px;
  max-height: min(80vh, 980px);
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
}

.chat-bubble {
  max-width: min(72%, 520px);
  margin-bottom: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(17, 42, 63, 0.95);
  border: 1px solid rgba(126, 205, 255, 0.12);
}

.chat-bubble--mine {
  margin-left: auto;
  background: linear-gradient(135deg, rgba(47, 229, 125, 0.22), rgba(31, 192, 255, 0.18));
}

.chat-bubble__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  color: #89b7d4;
}

.chat-bubble__body {
  font-size: 14px;
  line-height: 1.6;
  color: #f4fbff;
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-bubble__translation {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(126, 205, 255, 0.12);
  font-size: 13px;
  line-height: 1.55;
  color: #c3def1;
}

.chat-composer {
  padding: 10px 12px;
}

.chat-composer-input {
  min-height: 90px;
  padding: 12px 14px;
  font-size: 14px;
}

.chat-composer__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.chat-counter {
  font-size: 12px;
  color: #89b7d4;
}

.chat-action-button,
.chat-send-button {
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
}

.chat-action-button {
  background: rgba(255, 255, 255, 0.08);
  color: #f4fbff;
}

.chat-send-button {
  background: linear-gradient(135deg, #2fe57d, #1fc0ff);
  color: #042033;
  font-weight: 800;
}

.wallet-avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background: var(--wallet-avatar-bg, #3b82f6);
  color: #f8fcff;
  font-weight: 800;
  letter-spacing: 0.02em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.wallet-avatar--sm {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  font-size: 14px;
}

.wallet-avatar--md {
  width: 42px;
  height: 42px;
  font-size: 16px;
}

.wallet-list-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.wallet-list-item.is-active {
  border-color: rgba(47, 229, 125, 0.5);
  background: rgba(47, 229, 125, 0.12);
}

.wallet-list-item__content {
  min-width: 0;
  flex: 1;
}

.friend-tools-panel {
  display: grid;
  align-content: start;
  gap: 14px;
}

.template-delivery-card {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 20px;
  border: 1px solid rgba(137, 192, 255, 0.14);
  background: rgba(255, 255, 255, 0.03);
}

.template-delivery-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.template-delivery-card__actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.template-delivery-card__actions .btn {
  min-width: 150px;
}

.template-delivery-card__head h3 {
  margin: 0 0 6px;
  font-size: 20px;
}

.template-delivery-card__head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.template-delivery-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  font-size: 13px;
  color: var(--muted);
}

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

.template-file-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(137, 192, 255, 0.12);
  background: rgba(8, 22, 32, 0.58);
}

.template-file-item.is-active {
  border-color: rgba(47, 229, 125, 0.4);
  background: rgba(47, 229, 125, 0.08);
}

.template-file-item__meta {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.template-file-item__meta strong {
  display: block;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.template-file-item__meta span {
  color: var(--muted);
  font-size: 12px;
}

.template-file-item__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.compact-list-box {
  min-height: 0;
  padding: 12px;
}

.friend-list-box {
  min-height: 360px;
  max-height: 620px;
  overflow: auto;
}

.friend-access-settings-form {
  display: grid;
  gap: 12px;
}

.friend-access-toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.friend-access-toggle input {
  width: auto;
  margin: 0;
}

.friend-access-price-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.chat-side-item__row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chat-side-item__content {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.chat-search-result-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chat-bubble-row {
  align-items: flex-end;
  gap: 10px;
}

.chat-bubble-row--mine {
  justify-content: flex-end;
}

.chat-bubble-row--mine .chat-bubble-avatar {
  order: 2;
}

.chat-bubble-row--mine .chat-bubble {
  order: 1;
}

.chat-message-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.chat-message-row--self {
  justify-content: flex-end;
}

.chat-message-row--self .chat-message-avatar {
  order: 2;
}

.chat-message-row--self .chat-message {
  order: 1;
}

.chat-message-avatar,
.chat-bubble-avatar {
  margin-bottom: 4px;
}

.chat-panel-large {
  display: grid;
  align-content: start;
}

.chat-box--large {
  min-height: 640px;
  max-height: 760px;
}

.status-box[data-tone="error"] {
  border-color: rgba(251, 113, 133, 0.3);
  color: #ffd5dc;
}

.status-box[data-tone="success"] {
  border-color: rgba(74, 222, 128, 0.28);
  color: #dfffe9;
}

@media (max-width: 960px) {
  .chat-drawer {
    width: calc(100vw - 12px);
    right: 6px;
    left: 6px;
    bottom: 6px;
    top: auto;
    max-height: calc(100vh - 12px);
    border-radius: 24px;
  }

  .chat-toolbar--qq {
    grid-template-columns: 1fr;
  }

  .chat-language-select--compact {
    width: 100%;
    min-width: 0;
  }

  .dashboard-columns--template,
  .chat-sections--qq {
    grid-template-columns: 1fr;
  }

  .chat-side-panel--qq,
  .chat-main-panel--qq {
    min-height: 0;
  }

  .template-file-item {
    grid-template-columns: 1fr;
  }

  .template-file-item__actions {
    justify-content: flex-start;
  }

  .template-delivery-card__head,
  .template-delivery-card__actions {
    flex-direction: column;
    align-items: flex-start;
  }

  .chat-friend-list,
  .chat-message-list {
    min-height: 280px;
  }

  .chat-bubble {
    max-width: 100%;
  }
}
