:root {
  --bg: #f4f5f6;
  --panel: #ffffff;
  --panel-2: #f8f8f8;
  --text: #222222;
  --muted: #7a7a7a;
  --faint: #a3a3a3;
  --line: #e9eaec;
  --line-strong: #d8dadd;
  --accent: #de0422;
  --accent-deep: #b81b1b;
  --merchant: #0d7c66;
  --member: #9a6a12;
  --link: #1f66c7;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  letter-spacing: 0;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--link);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1000px;
  margin: 0 auto;
  padding: 9px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
}

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

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  flex: none;
}

.brand-name {
  font-weight: 700;
  font-size: 17px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.public-topbar .top-actions {
  margin-left: 0;
}

.live-clock {
  margin-left: auto;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
  line-height: 1.1;
}

.clock-strip {
  display: flex;
  justify-content: center;
  padding: 10px 0 14px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 10px;
}

.clock-strip time {
  display: inline-flex;
  align-items: baseline;
  gap: 12px;
}

.clock-strip .clock-date {
  font-size: 30px;
  color: var(--text);
}

.clock-strip .clock-time {
  font-size: 30px;
  color: var(--text);
}

.clock-date {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.clock-time {
  font-size: 28px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  white-space: nowrap;
}

.live-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34a853;
  box-shadow: 0 0 0 3px rgba(52, 168, 83, 0.14);
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  width: 34px;
  height: 34px;
  border-radius: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-btn:hover {
  border-color: var(--line-strong);
  background: var(--panel-2);
}

.icon-btn.is-on {
  border-color: var(--accent);
  color: var(--accent);
}

.content-wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 14px 18px 80px;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.seg {
  display: inline-flex;
  padding: 0;
  background: transparent;
  border-radius: 0;
  border: 0;
  border-bottom: 2px solid var(--line);
  width: 100%;
}

.seg button {
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  background: transparent;
  color: #555555;
  padding: 6px 12px;
  border-radius: 0;
  font-weight: 500;
}

.seg button.active {
  background: transparent;
  color: var(--accent);
  border-bottom-color: var(--accent);
  box-shadow: none;
}

.seg .count {
  margin-left: 4px;
  color: var(--faint);
  font-size: 12px;
}

.update-toast {
  margin: 0 0 10px;
  display: none;
  border: 1px solid rgba(222, 4, 34, 0.2);
  background: #fdf0f1;
  color: var(--accent);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

.update-toast.show {
  display: block;
}

.feed {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}

.message-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px 12px;
  padding: 13px 16px;
  border-top: 1px solid var(--line);
}

.message-row:first-child {
  border-top: 0;
}

.message-row.is-pinned {
  box-shadow: inset 3px 0 0 var(--accent);
  background: #fffaf8;
}

.message-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  display: inline;
  padding: 0;
  margin: 0;
  font-size: 12px;
  white-space: nowrap;
}

.message-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.sender {
  font-weight: 650;
  font-size: 13px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 18px;
  padding: 0 6px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}

.badge-merchant {
  background: #e4f3ee;
  color: var(--merchant);
}

.badge-member {
  background: #f8eed4;
  color: var(--member);
}

.badge-pinned {
  background: #fbe5e3;
  color: var(--accent);
}

.message-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #222222;
  font-size: 15px;
}

.message-content.is-long {
  max-height: 112px;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 60%, transparent);
  mask-image: linear-gradient(#000 60%, transparent);
}

.expand-btn {
  border: 0;
  background: transparent;
  color: var(--link);
  padding: 0;
  font-size: 13px;
}

.style-color .message-content {
  color: #e0281f;
  font-weight: 800;
  text-shadow: 0 1px 0 rgba(224, 40, 31, 0.12);
}

.style-frame .message-content {
  padding: 12px 14px;
  border-radius: 10px;
  border: 2px solid transparent;
  background:
    linear-gradient(#fffdfb, #fffdfb) padding-box,
    linear-gradient(120deg, #ff4d3d, #ff9f1c, #e544e5, #4f8cff, #12b886, #ff4d3d) border-box;
  box-shadow: 0 2px 16px rgba(255, 77, 61, 0.16);
}

.style-big .message-content {
  font-size: 22px;
  font-weight: 900;
  line-height: 1.5;
  color: #15171a;
  background: linear-gradient(0deg, #fff4e2, #fffdf6);
  border-radius: 8px;
  padding: 8px 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 158, 60, 0.28);
}

.media-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  max-width: 100%;
  align-items: flex-start;
}

.media-grid img {
  display: block;
  width: auto;
  max-width: 132px;
  max-height: 132px;
  height: auto;
  object-fit: contain;
  cursor: zoom-in;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: #f2f3f4;
}

.feed-footer {
  padding: 12px;
  text-align: center;
  border-top: 1px solid var(--line);
}

.text-btn {
  border: 0;
  background: transparent;
  color: var(--link);
  padding: 4px 8px;
  font-size: 13px;
}

.empty-state {
  padding: 50px 20px;
  text-align: center;
  color: var(--muted);
}

.footnote {
  max-width: 960px;
  margin: 22px auto;
  padding: 0 18px;
  color: var(--faint);
  font-size: 12px;
}

.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 14, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.lightbox.show {
  display: flex;
}

.lightbox img {
  max-width: min(92vw, 1100px);
  max-height: 90vh;
  border-radius: 6px;
}

/* simulator */
.page-body {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px;
}

.split {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 14px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.panel h2,
.panel h3 {
  margin: 0 0 10px;
  font-size: 14px;
}

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

.persona-item {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 9px 10px;
  text-align: left;
}

.persona-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(222, 4, 34, 0.18);
}

.field {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
}

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

.input,
.textarea,
.select {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  padding: 9px 10px;
}

.textarea {
  min-height: 90px;
  resize: vertical;
}

.input:focus,
.textarea:focus,
.select:focus {
  outline: 2px solid rgba(34, 103, 198, 0.22);
  border-color: var(--link);
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 500;
}

.btn-primary {
  border-color: var(--text);
  background: var(--text);
  color: #fff;
}

.btn-danger {
  border-color: #f2c4c1;
  background: #fbe9e8;
  color: var(--accent);
}

.btn-sm {
  padding: 4px 9px;
  font-size: 12px;
  border-radius: 6px;
}

.chat {
  min-height: 420px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-message {
  max-width: 78%;
  padding: 9px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.chat-message.from-user {
  align-self: flex-end;
  background: #e9f3fc;
  border-color: #c9dcf0;
}

.chat-message .chat-label {
  display: block;
  font-size: 11px;
  color: var(--faint);
  margin-bottom: 3px;
}

.status-line {
  color: var(--muted);
  font-size: 12px;
}

/* admin */
.admin-grid {
  display: grid;
  gap: 12px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.stat-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px 14px;
}

.stat-num {
  font-size: 22px;
  font-weight: 700;
}

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

.account-body {
  max-width: 1000px;
}

.account-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 14px;
}

.account-grid > .panel {
  min-width: 0;
}

.account-grid .panel:nth-child(odd):last-child {
  grid-column: 1 / -1;
}

.account-switcher {
  margin-top: 0;
}

.wallet-balance {
  font-size: 30px;
  font-weight: 700;
  margin: 2px 0 10px;
  font-variant-numeric: tabular-nums;
}

.profile-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}

.profile-row:last-child {
  border-bottom: 0;
}

.price-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.price-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.price-card h3 {
  margin: 0;
  font-size: 14px;
}

.price-card .price {
  font-size: 20px;
  font-weight: 700;
}

.price-card .original {
  color: var(--faint);
  text-decoration: line-through;
  font-size: 12px;
  font-weight: 400;
  margin-left: 6px;
}

.price-card .bonus {
  color: var(--merchant);
  font-size: 12px;
}

.price-card .buy-btn {
  margin-top: auto;
}

.tabs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  margin-bottom: 12px;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  padding: 7px 12px;
  color: var(--muted);
}

.tab.active {
  background: var(--panel);
  border-color: var(--line);
  color: var(--text);
  box-shadow: var(--shadow);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

th,
td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 13px;
}

th {
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

.badge-status {
  display: inline-flex;
  padding: 2px 7px;
  border-radius: 20px;
  font-size: 11px;
  background: #eef0f2;
  color: var(--muted);
  white-space: nowrap;
}

.badge-status.published,
.badge-status.approved {
  background: #e2f3e9;
  color: #177245;
}

.badge-status.pending_manual,
.badge-status.pending_ai,
.badge-status.pending_bind,
.badge-status.pending {
  background: #fdf1dd;
  color: #8a5b06;
}

.badge-status.blocked,
.badge-status.rejected {
  background: #fbe3e1;
  color: #b42318;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 10px;
}

.settings-item input {
  margin-top: 5px;
}

.muted {
  color: var(--muted);
}

.danger-zone {
  border-color: #efc9c6;
  background: #fff8f7;
}

@media (max-width: 760px) {
  .split {
    grid-template-columns: 1fr;
  }

  .account-grid {
    grid-template-columns: 1fr;
  }

  .message-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }

  .message-time {
    padding: 0;
  }

  .topbar-inner {
    padding: 8px 12px;
  }

  .live-state {
    display: none;
  }

  .content-wrap {
    padding: 10px 12px 60px;
  }
}

@media (max-width: 640px) {
  body {
    overflow-x: hidden;
  }

  .topbar-inner {
    flex-wrap: wrap;
    min-height: auto;
    padding: 8px 12px;
  }

  .top-actions {
    margin-left: 0;
  }

  .clock-strip {
    padding: 8px 0 12px;
  }

  .clock-strip time {
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }

  .clock-strip .clock-date {
    font-size: 26px;
  }

  .clock-strip .clock-time {
    font-size: 26px;
    color: var(--text);
  }

  .message-row {
    padding: 10px 12px;
  }

  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }

  .panel {
    padding: 10px;
  }

  .chat-message {
    max-width: 92%;
  }

  .row .field {
    min-width: 100%;
  }

  .row .select {
    width: 100%;
  }

  .stat-card {
    padding: 10px 12px;
  }

  .btn,
  .btn-sm {
    white-space: nowrap;
  }

  .table-wrap {
    margin: 0 -10px;
    padding: 0 10px;
    width: calc(100% + 20px);
  }

  table {
    min-width: 680px;
  }

  .feed-footer .text-btn {
    width: 100%;
  }
}

@media (min-width: 761px) and (max-width: 1024px) {
  .content-wrap,
  .topbar-inner,
  .footnote {
    max-width: 960px;
  }

  .split {
    grid-template-columns: 250px 1fr;
  }
}

.merchant-sender {
  border: 0;
  background: transparent;
  padding: 0;
  color: inherit;
  font-weight: 650;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}

.merchant-sender:hover {
  color: var(--merchant);
}

.merchant-dialog {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 18px;
}

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

.merchant-card {
  width: min(100%, 420px);
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--line);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
  padding: 18px;
}

.merchant-card h3 {
  margin: 0 0 10px;
  font-size: 18px;
}

.merchant-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}

.merchant-line span:first-child {
  color: var(--muted);
  flex: none;
}

.merchant-line span:last-child {
  text-align: right;
  overflow-wrap: anywhere;
}

.chat-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-self: flex-start;
}

.style-color_red .message-content {
  color: #e0281f;
  font-weight: 800;
  text-shadow: 0 1px 0 rgba(224, 40, 31, 0.12);
}

.style-color_orange .message-content {
  color: #f2761b;
  font-weight: 800;
  text-shadow: 0 1px 0 rgba(242, 118, 27, 0.12);
}

.style-color_blue .message-content {
  color: #1767e0;
  font-weight: 800;
  text-shadow: 0 1px 0 rgba(23, 103, 224, 0.12);
}

.style-color_green .message-content {
  color: #0e9d5f;
  font-weight: 800;
  text-shadow: 0 1px 0 rgba(14, 157, 95, 0.12);
}

.style-color_purple .message-content {
  color: #7c3aed;
  font-weight: 800;
  text-shadow: 0 1px 0 rgba(124, 58, 237, 0.12);
}

.style-color_pink .message-content {
  color: #e04aa1;
  font-weight: 800;
  text-shadow: 0 1px 0 rgba(224, 74, 161, 0.12);
}
