:root {
  --orange: #ff6a00;
  --orange-dark: #e85f00;
  --ink: #333;
  --muted: #999;
  --line: #e3e3e3;
  --bg: #f4f4f4;
  --radius: 8px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 20px;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; }

.container {
  max-width: 1000px;
  margin: 0 auto;
  background: #fff;
  padding: 20px 22px 10px;
  border-radius: var(--radius);
  box-shadow: 0 0 15px rgba(0, 0, 0, .05);
}

.site-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 0 14px;
  border-bottom: 1px solid #f1f1f1;
  margin-bottom: 18px;
}

.brand {
  font-size: 19px;
  font-weight: 700;
  color: var(--orange);
  text-decoration: none;
  letter-spacing: .5px;
}

.admin-link {
  font-size: 12px;
  color: #999;
  text-decoration: none;
  border: 1px solid #e5e5e5;
  padding: 5px 10px;
  border-radius: 4px;
  transition: .2s;
}

.admin-link:hover { color: var(--orange); border-color: var(--orange); }

.ad-section {
  margin-bottom: 22px;
  border: 1px solid #e2e2e2;
  border-radius: var(--radius);
  overflow: hidden;
}

.ad-section-header {
  background: var(--orange);
  color: #fff;
  padding: 10px 16px;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.header-link {
  color: #fff;
  text-decoration: none;
  font-size: 12.5px;
  background: rgba(255, 255, 255, .2);
  padding: 5px 10px;
  border-radius: 4px;
  transition: background .2s;
  white-space: nowrap;
}

.header-link:hover { background: rgba(255, 255, 255, .38); }
.header-link.soldout { opacity: .7; }

.ad-section-body { padding: 16px; }

.ad-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr));
  gap: var(--gap, 5px);
}

.text-ad {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 40px;
  padding: 8px 6px;
  border: 1px solid #e0e0e0;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  text-decoration: none;
  overflow: hidden;
  transition: transform .2s, box-shadow .2s;
  word-break: break-word;
}

.text-ad:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, .1);
}

.text-ad.empty {
  color: #9a9a9a;
  background: #fafafa;
  border-style: dashed;
  font-weight: 400;
}

.image-slot {
  position: relative;
  display: block;
  border-radius: 6px;
  overflow: hidden;
  background: #f7f7f7;
}

.image-slot > a {
  display: block;
  width: 100%;
  height: 100%;
}

.image-slot img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-slot.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: 1px dashed #d8d8d8;
  color: #a2a2a2;
  font-size: 13px;
  text-decoration: none;
  transition: border-color .2s, color .2s, background .2s;
  min-height: 60px;
}

.image-slot.empty:hover {
  border-color: var(--orange);
  color: var(--orange);
  background: #fffaf6;
}

.ad-expire-tip,
.buy-tip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 3px 6px;
  font-size: 10px;
  font-weight: 400;
  line-height: 1.3;
  text-align: center;
  color: #fff;
  background: rgba(0, 0, 0, .75);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
  z-index: 2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.buy-tip {
  background: rgba(255, 106, 0, .92);
  font-size: 10.5px;
}

@media (hover: hover) {
  .ad-sold:hover .ad-expire-tip { opacity: 1; }
  .empty:hover .buy-tip { opacity: 1; }
}

.show-tip .ad-expire-tip,
.show-tip .buy-tip { opacity: 1; }

.footer {
  text-align: center;
  margin-top: 26px;
  padding: 14px 0 6px;
  color: #999;
  font-size: 12.5px;
  border-top: 1px solid #f3f3f3;
}

.empty-page { padding: 40px 0; text-align: center; color: #999; }

/* ---------- 购买页 ---------- */

.page-head { margin: 4px 0 18px; }

.back {
  font-size: 12.5px;
  color: #999;
  text-decoration: none;
}

.back:hover { color: var(--orange); }

.page-head h1 {
  font-size: 21px;
  margin: 10px 0 4px;
}

.page-head .sub {
  margin: 0;
  color: #999;
  font-size: 13px;
}

.alert {
  background: #fff4f4;
  border: 1px solid #ffd9d9;
  color: #d33;
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
}

.link-back { font-size: 13px; }
.link-back a { color: var(--orange); }

.buy-form { max-width: 560px; }

.field { margin-bottom: 16px; }

.field > label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 7px;
}

.field input[type=text],
.field input[type=url],
.field input[type=password],
.field input[type=email],
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s;
  background: #fff;
  color: var(--ink);
}

.field input:focus,
.field select:focus,
.field textarea:focus { border-color: var(--orange); }

.field-row { display: flex; gap: 14px; }
.field-row .field { flex: 1; }

.field input[type=color] {
  width: 64px;
  height: 38px;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 3px;
  background: #fff;
  cursor: pointer;
}

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

.period { cursor: pointer; }
.period input { display: none; }

.period span {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 18px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  color: #666;
  transition: .2s;
}

.period b { font-size: 15px; color: #333; }

.period input:checked + span {
  border-color: var(--orange);
  background: #fff8f3;
  color: var(--orange);
}

.period input:checked + span b { color: var(--orange); }

.preview-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: -2px 0 16px;
}

.preview-label { font-size: 12px; color: #aaa; }

.text-ad.preview {
  min-width: 150px;
  border: 1px solid #e0e0e0;
  border-radius: 5px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: static;
  transform: none !important;
  box-shadow: none !important;
}

.upload-box {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 1.5px dashed #d8d8d8;
  border-radius: 8px;
  padding: 20px;
  cursor: pointer;
  color: #999;
  font-size: 12.5px;
  transition: .2s;
  line-height: 1.6;
}

.upload-box:hover {
  border-color: var(--orange);
  color: var(--orange);
  background: #fffaf6;
}

.upload-box input { display: none; }

.img-preview {
  margin: 0 0 16px;
  border: 1px solid #eee;
  border-radius: 6px;
  overflow: hidden;
  max-width: 100%;
}

.field-hint {
  margin-top: 6px;
  font-size: 12px;
  color: #aaa;
  line-height: 1.6;
}

.img-preview img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: #fafafa;
}

.total {
  font-size: 15px;
  margin: 20px 0 14px;
  color: #666;
}

.total b {
  font-size: 24px;
  color: #e53935;
  margin-left: 4px;
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 13px 18px;
  background: var(--orange);
  color: #fff;
  border: 0;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background .2s;
  font-family: inherit;
}

.btn-primary:hover { background: var(--orange-dark); }

/* ---------- 站点与订单 ---------- */

.sites-box {
  background: #fafafa;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 18px;
  max-width: 560px;
}

.sites-box h3 {
  margin: 0 0 8px;
  font-size: 13px;
  color: #666;
}

.sites-box ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin: 0;
  padding: 0;
}

.sites-box a {
  font-size: 12.5px;
  color: #666;
  text-decoration: none;
}

.sites-box a:hover { color: var(--orange); }

.order-card {
  border: 1px solid #eee;
  border-radius: 8px;
  overflow: hidden;
  max-width: 520px;
  margin-bottom: 18px;
}

.order-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #f3f3f3;
  font-size: 13px;
}

.order-line:last-child { border-bottom: 0; }
.order-line span { color: #999; }
.order-line b { font-weight: 600; }
.order-line .price { color: #e53935; font-size: 18px; }

.qr-row { display: flex; gap: 18px; margin: 0 0 16px; }

.qr {
  text-align: center;
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 12px;
}

.qr img {
  width: 150px;
  height: 150px;
  object-fit: contain;
  display: block;
  margin-bottom: 6px;
}

.qr span { font-size: 12px; color: #999; }

.pay-note {
  font-size: 12.5px;
  color: #999;
  margin: 0 0 16px;
  max-width: 520px;
}

/* 支付通道 */

.channel-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 520px;
  margin-bottom: 16px;
}

.channel-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid #e5e5e5;
  border-radius: 8px;
  text-decoration: none;
  color: #333;
  transition: border-color .2s, box-shadow .2s, transform .2s;
}

.channel-btn:hover {
  border-color: var(--orange);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .06);
  transform: translateY(-1px);
}

.channel-ico {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex: 0 0 32px;
}

.channel-ico.wxpay { background: #07c160; }
.channel-ico.alipay { background: #1677ff; }

.channel-txt { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.channel-txt b { font-size: 14px; font-weight: 600; }
.channel-txt em { font-size: 12px; color: #999; font-style: normal; }
.channel-arrow { color: #ccc; font-size: 18px; }

.paid-box {
  border: 1px solid #e6f5e9;
  background: #f7fdf9;
  border-radius: 8px;
  padding: 22px;
  text-align: center;
  max-width: 560px;
}

.paid-box.pending {
  border-color: #ffe9c9;
  background: #fffbf4;
}

.paid-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #2eb872;
  color: #fff;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 10px;
}

.paid-box p { color: #4a8b63; font-size: 13px; }
.paid-box.pending p { color: #a67a2c; }

.paid-preview {
  margin: 14px 0 18px;
  text-align: left;
}

.paid-preview .text-ad { min-height: 40px; }

.paid-box .btn-primary { max-width: 240px; margin: 0 auto; }

/* ---------- 嵌入模式 ---------- */

body.embed-body {
  margin: 0 auto;
  padding: 0 24px;
  max-width: 1048px;
  background: transparent;
  box-sizing: border-box;
  overflow: hidden;
}

.embed-body .ad-grid + .ad-grid { margin-top: 12px; }

/* 嵌入时：手机端左右只留一点点 */
@media (max-width: 640px) {
  body.embed-body {
    padding: 0 8px;
  }
}

/* ---------- 手机端 ---------- */

@media (max-width: 640px) {
  body { padding: 10px; }
  .container { padding: 14px 13px 6px; }
  .site-head { margin-bottom: 14px; padding-bottom: 12px; }
  .brand { font-size: 17px; }
  .ad-section-header { padding: 9px 12px; font-size: 15px; }
  .ad-section-body { padding: 10px; }
  .ad-grid { grid-template-columns: repeat(var(--cols-m, 2), minmax(0, 1fr)); }
  .text-ad { font-size: 11.5px; padding: 7px 4px; min-height: 38px; }
  .page-head h1 { font-size: 19px; }
  .total b { font-size: 22px; }
  .field-row { gap: 10px; }
}
