/* cxbot 前端样式：零依赖、移动端优先、无框架 */
:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --ink: #1f2430;
  --ink-2: #5b6474;
  --line: #e6e8ee;
  --brand: #4f46e5;
  --brand-ink: #ffffff;
  --price: #ef4444;
  --ok: #16a34a;
  --run: #2563eb;
  --wait: #d97706;
  --err: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

/* 关键：显式 display 的组件（.drawer / .modal）会覆盖 hidden 的默认 display:none，
   导致"透明但拦截点击"的遮罩。这条规则保证 hidden 永远真的隐藏。 */
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body.locked { overflow: hidden; }

img { max-width: 100%; display: block; }

button { font: inherit; cursor: pointer; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }

.muted { color: var(--ink-2); font-size: 13px; }

.empty { color: var(--ink-2); text-align: center; padding: 32px 0; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: #111827;
  color: #f9fafb;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .06);
}
.topbar-inner {
  display: flex; align-items: center; gap: 16px;
  height: 60px;
}
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; flex: 0 0 auto; }
.brand-logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, #6366f1, #a855f7);
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
  overflow: hidden;
}
.brand-logo img { width: 100%; height: 100%; object-fit: cover; }
.brand-name { font-weight: 650; letter-spacing: .2px; }

.search { display: flex; flex: 1 1 auto; max-width: 460px; }
.search input {
  flex: 1; height: 36px; padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, .14);
  border-right: 0; border-radius: 9px 0 0 9px;
  background: rgba(255, 255, 255, .08); color: #f9fafb; outline: none;
}
.search input::placeholder { color: rgba(249, 250, 251, .55); }
.search input:focus { background: rgba(255, 255, 255, .14); }
.search button {
  height: 36px; padding: 0 16px; border: 0; border-radius: 0 9px 9px 0;
  background: var(--brand); color: var(--brand-ink); font-weight: 600;
}

.topnav { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.link {
  background: none; border: 0; color: rgba(249, 250, 251, .82);
  padding: 8px 10px; border-radius: 8px; text-decoration: none; font-size: 14px;
}
.link:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.login { border: 1px solid rgba(255, 255, 255, .2); }

/* ---------- 公告 ---------- */
.notice { background: #fffbeb; border-bottom: 1px solid #fde68a; }
.notice-inner { display: flex; align-items: center; gap: 10px; padding: 9px 16px; font-size: 13px; color: #92400e; }
.notice-tag { background: #f59e0b; color: #fff; border-radius: 5px; padding: 1px 7px; font-size: 12px; }
.notice-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notice-more { background: none; border: 0; color: #b45309; text-decoration: underline; font-size: 13px; }

/* ---------- 主区 ---------- */
.main { padding: 20px 16px 56px; }

.page[hidden] { display: none; }

/* ---------- 轮播 ---------- */
.banner {
  position: relative; overflow: hidden; border-radius: var(--radius);
  background: linear-gradient(120deg, #eef2ff, #f5f3ff);
  box-shadow: var(--shadow);
}
.banner[hidden] { display: none; }
.banner-track { display: flex; transition: transform .45s ease; }
.banner-slide {
  flex: 0 0 100%; position: relative; height: 190px;
  display: grid; place-items: center; color: var(--ink);
  text-decoration: none; background: linear-gradient(120deg, #e0e7ff, #ede9fe);
}
.banner-slide img { width: 100%; height: 100%; object-fit: cover; }
.banner-caption {
  position: absolute; left: 20px; bottom: 16px;
  background: rgba(17, 24, 39, .68); color: #fff;
  padding: 6px 12px; border-radius: 8px; font-size: 14px;
}
.banner-dots { position: absolute; right: 14px; bottom: 14px; display: flex; gap: 6px; }
.banner-dot {
  width: 8px; height: 8px; border-radius: 50%; border: 0;
  background: rgba(255, 255, 255, .55); padding: 0;
}
.banner-dot.active { background: var(--brand); width: 18px; border-radius: 4px; }

/* ---------- 分类 ---------- */
.cats { display: flex; gap: 8px; flex-wrap: wrap; margin: 18px 0 6px; }
.cat {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  padding: 6px 14px; border-radius: 999px; font-size: 14px;
}
.cat:hover { border-color: var(--brand); color: var(--brand); }
.cat.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.section-head { display: flex; align-items: baseline; gap: 10px; margin: 18px 0 12px; }
.section-head h2 { font-size: 18px; margin: 0; }

/* ---------- 商品网格 ---------- */
.goods-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.goods-card {
  background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); cursor: pointer; transition: transform .18s, box-shadow .18s;
  outline: none; display: flex; flex-direction: column;
}
.goods-card:hover, .goods-card:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 2px 4px rgba(16, 24, 40, .06), 0 12px 28px rgba(16, 24, 40, .12);
}
.goods-cover {
  aspect-ratio: 16 / 9; background: linear-gradient(120deg, #e0e7ff, #fae8ff);
  display: grid; place-items: center; overflow: hidden;
}
.goods-cover img { width: 100%; height: 100%; object-fit: cover; }
.cover-fallback { font-size: 34px; font-weight: 700; color: #6366f1; opacity: .7; }
.goods-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.goods-title {
  font-size: 15px; font-weight: 600; margin: 0; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.goods-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; }
.price { color: var(--price); font-weight: 700; font-size: 18px; }

.labels { display: flex; gap: 6px; flex-wrap: wrap; }
.label {
  --label-color: #6366f1;
  font-size: 12px; padding: 1px 8px; border-radius: 6px;
  color: var(--label-color);
  background: color-mix(in srgb, var(--label-color) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--label-color) 35%, transparent);
}

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 22px 0 0; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 9px 16px; border-radius: 10px; font-weight: 600; transition: .15s;
}
.btn:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover:not(:disabled) { filter: brightness(1.07); color: #fff; }
.btn.ghost { background: #fff; }
.btn.tiny { padding: 4px 10px; font-size: 13px; border-radius: 8px; }

/* ---------- 商品详情 ---------- */
.back {
  background: none; border: 0; color: var(--ink-2); padding: 6px 0; margin-bottom: 8px;
}
.back:hover { color: var(--brand); }

.goods-detail {
  display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 20px;
}
.gallery-main {
  border-radius: 12px; overflow: hidden; background: #f3f4f6; aspect-ratio: 4 / 3;
  display: grid; place-items: center;
}
.gallery-main img { width: 100%; height: 100%; object-fit: cover; }
.gallery-thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.thumb {
  width: 64px; height: 48px; padding: 0; border: 2px solid transparent;
  border-radius: 8px; overflow: hidden; background: #f3f4f6;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.active { border-color: var(--brand); }

.buybox h1 { font-size: 20px; margin: 0 0 10px; line-height: 1.4; }
.price-row { display: flex; align-items: baseline; gap: 12px; margin: 12px 0 6px; }
.price-row .price { font-size: 26px; }
.sales { margin-bottom: 14px; }

.dynform { display: flex; flex-direction: column; gap: 12px; margin: 8px 0 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; color: var(--ink-2); }
.control {
  height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; color: var(--ink); outline: none; width: 100%;
}
.control:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .12); }
select.control { appearance: none; background-image: linear-gradient(45deg, transparent 50%, #98a2b3 50%), linear-gradient(135deg, #98a2b3 50%, transparent 50%); background-position: calc(100% - 18px) 16px, calc(100% - 13px) 16px; background-size: 5px 5px; background-repeat: no-repeat; }

.course-tools { display: flex; align-items: center; gap: 10px; margin: 2px 0 14px; flex-wrap: wrap; }

.payways { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.card-row { margin-bottom: 14px; }
.payway {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  padding: 7px 12px; border-radius: 10px; font-size: 13px;
}
.payway.active { border-color: var(--brand); color: var(--brand); background: #eef2ff; }

.buy-actions { display: flex; gap: 10px; }
.buy-actions .btn { flex: 1; height: 42px; }
.buy-actions .btn.primary { flex: 2; }
.hint { margin: 10px 0 0; min-height: 18px; }

.notice-box {
  margin-top: 18px; background: #fff7ed; border: 1px solid #fed7aa;
  border-radius: var(--radius); padding: 16px 18px;
}
.notice-box h3 { margin: 0 0 8px; font-size: 15px; color: #9a3412; }
.plain { white-space: pre-wrap; word-break: break-word; margin: 0; font: inherit; color: var(--ink-2); }

/* 蜜罐字段：不可见但存在于 DOM，脚本填充即被判为机器人 */
.hp-trap {
  position: absolute !important;
  left: -9999px !important;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ---------- 抽屉 ---------- */
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(460px, 100%);
  background: #fff; box-shadow: -12px 0 40px rgba(16, 24, 40, .18);
  transform: translateX(100%); transition: transform .22s ease;
  display: flex; flex-direction: column; z-index: 60;
}
.drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.drawer-head h3 { margin: 0; font-size: 16px; }
.drawer-body { padding: 16px 18px; overflow: auto; flex: 1; }
.close { background: none; border: 0; font-size: 22px; line-height: 1; color: var(--ink-2); }

.inline-form { display: flex; gap: 8px; margin-bottom: 14px; }
.inline-form input {
  flex: 1; height: 38px; padding: 0 12px; border: 1px solid var(--line);
  border-radius: 10px; outline: none;
}
.inline-form input:focus { border-color: var(--brand); }

/* ---------- 课程条目 ---------- */
.course-items { display: flex; flex-direction: column; gap: 10px; }
.course-item {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.course-item.picked { border-color: var(--brand); background: #eef2ff; }
.course-main { flex: 1; min-width: 0; }
.course-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.course-sub { font-size: 12px; }
.course-state {
  font-size: 12px; padding: 2px 9px; border-radius: 999px; white-space: nowrap;
  background: #f1f5f9; color: var(--ink-2);
}
.course-state.ok { background: #dcfce7; color: var(--ok); }
.course-state.run { background: #dbeafe; color: var(--run); }
.course-state.wait { background: #fef3c7; color: var(--wait); }
.course-state.err { background: #fee2e2; color: var(--err); }

/* ---------- 订单 ---------- */
.order-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.order-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.order-no { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; color: var(--ink-2); }
.badge { font-size: 12px; padding: 2px 10px; border-radius: 999px; background: #f1f5f9; color: var(--ink-2); }
.badge.ok { background: #dcfce7; color: var(--ok); }
.badge.run { background: #dbeafe; color: var(--run); }
.badge.wait { background: #fef3c7; color: var(--wait); }
.badge.err { background: #fee2e2; color: var(--err); }

.order-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.order-box { background: #fafbfc; border-radius: 10px; padding: 10px 12px; }
.order-box h4 { margin: 0 0 6px; font-size: 13px; color: var(--ink-2); }
.order-box ul { margin: 0; padding-left: 16px; font-size: 13px; color: var(--ink); }
.order-box li { word-break: break-all; }

/* ---------- 弹层 ---------- */
.modal {
  position: fixed; inset: 0; z-index: 80; display: grid; place-items: center;
  background: rgba(17, 24, 39, .45); padding: 16px;
  opacity: 0; transition: opacity .18s;
}
.modal.open { opacity: 1; }
.modal-card {
  width: min(560px, 100%); max-height: 86vh; background: #fff; border-radius: 16px;
  display: flex; flex-direction: column; overflow: hidden;
  transform: translateY(8px); transition: transform .18s;
}
.modal.open .modal-card { transform: translateY(0); }
.modal-card.wide { width: min(760px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 18px; border-top: 1px solid var(--line); }

/* ---------- 公告条目 ---------- */
.article-item {
  width: 100%; text-align: left; background: #fff; border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; margin-bottom: 10px;
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
}
.article-item:hover { border-color: var(--brand); }
.article-title { font-weight: 600; }
.article-time { font-size: 12px; }

/* ---------- 客服 ---------- */
.fab {
  position: fixed; right: 18px; bottom: 22px; z-index: 50;
  height: 46px; padding: 0 18px; border-radius: 999px; border: 0;
  background: var(--brand); color: #fff; font-weight: 600;
  box-shadow: 0 10px 24px rgba(79, 70, 229, .35);
}
.fab:hover { filter: brightness(1.08); }
.service { display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; }
.qrcode { width: 180px; height: 180px; object-fit: contain; border: 1px solid var(--line); border-radius: 12px; }

/* ---------- 页脚 ---------- */
.footer { border-top: 1px solid var(--line); background: #fff; padding: 18px 0; }
.footer .wrap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--ink-2); font-size: 13px; }
.footer .link { color: var(--ink-2); padding: 0; }
.footer .link:hover { color: var(--brand); background: none; }
.dot { opacity: .5; }

/* ---------- 轻提示 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translate(-50%, 8px);
  background: rgba(17, 24, 39, .92); color: #fff; padding: 10px 18px;
  border-radius: 10px; font-size: 14px; z-index: 100; max-width: min(560px, 90vw);
  opacity: 0; transition: .2s; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.warn { background: #b45309; }
.toast.ok { background: #15803d; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .goods-detail { grid-template-columns: 1fr; }
  .banner-slide { height: 150px; }
}

@media (max-width: 640px) {
  .topbar-inner { height: auto; padding: 10px 0; flex-wrap: wrap; gap: 10px; }
  .search { order: 3; max-width: none; flex: 1 1 100%; }
  .topnav { gap: 2px; }
  .link { padding: 6px 8px; font-size: 13px; }
  .brand-name { font-size: 15px; }
  .main { padding: 14px 12px 48px; }
  .goods-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
  .goods-body { padding: 10px 11px 12px; }
  .goods-title { font-size: 14px; }
  .price { font-size: 16px; }
  .buy-actions .btn { height: 44px; }
  .drawer { width: 100%; }
  .fab { right: 12px; bottom: 14px; }
  .banner-slide { height: 130px; }
}
