:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --ink: #1f2330;
  --muted: #6b7280;
  --brand: #7c3aed;
  --brand-2: #ec4899;
  --line: #ececf3;
  --ok: #16a34a;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(31, 35, 48, 0.06);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
.container { max-width: 1140px; margin: 0 auto; padding: 0 16px; }

/* Header */
header.site {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 16px; height: 62px; }
.logo { font-weight: 800; font-size: 20px; letter-spacing: .5px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2)); -webkit-background-clip: text; background-clip: text; color: transparent; white-space: nowrap; }
.search { flex: 1; display: flex; position: relative; }
.search input { width: 100%; padding: 10px 14px; border: 1px solid var(--line); border-radius: 999px; background: #fafafe; font-size: 14px; outline: none; }
.search input:focus { border-color: var(--brand); }
.nav { display: flex; align-items: center; gap: 18px; font-size: 14px; }
.nav a { color: var(--muted); }
.nav a:hover { color: var(--brand); }
.cart-badge { position: relative; }
.cart-badge .count { position: absolute; top: -8px; right: -10px; background: var(--brand-2); color: #fff; font-size: 11px; min-width: 18px; height: 18px; border-radius: 9px; display: flex; align-items: center; justify-content: center; padding: 0 4px; }

/* Hero */
.hero { background: linear-gradient(120deg, #ede9fe, #fce7f3); border-radius: 18px; padding: 34px 28px; margin: 22px 0; }
.hero h1 { margin: 0 0 8px; font-size: 26px; }
.hero p { margin: 0; color: var(--muted); }

/* Categories */
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.chip { padding: 7px 14px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font-size: 13px; cursor: pointer; color: var(--muted); }
.chip.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar select { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: #fff; }

/* Product grid */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); transition: transform .15s ease, box-shadow .15s ease; cursor: pointer; }
.card:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(31,35,48,.12); }
.card .thumb { aspect-ratio: 1/1; width: 100%; object-fit: cover; background: #f3f3f8; }
.card .body { padding: 12px 13px 14px; }
.card .cat { font-size: 11px; color: var(--brand); font-weight: 600; }
.card .name { font-size: 14px; font-weight: 600; margin: 4px 0 8px; height: 40px; overflow: hidden; }
.card .price { color: var(--brand-2); font-weight: 800; font-size: 17px; }
.card .price .old { color: var(--muted); font-weight: 500; font-size: 12px; text-decoration: line-through; margin-left: 6px; }
.card .meta { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 10px; border: 1px solid transparent; font-size: 14px; font-weight: 600; cursor: pointer; background: var(--brand); color: #fff; }
.btn:hover { opacity: .92; }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--brand); border-color: var(--brand); }
.btn.soft { background: #f3eefe; color: var(--brand); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.pink { background: var(--brand-2); }
.btn.gray { background: #eef0f4; color: var(--ink); }

/* Forms */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field input, .field textarea, .field select { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; outline: none; background: #fff; }
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--brand); }
.row { display: flex; gap: 12px; }
.row .field { flex: 1; }

/* Detail page —— 上方：主图 + 购买信息（两栏）；下方：全宽富文本介绍 */
.detail { padding: 24px 0; }
.detail-top { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.detail .gallery { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.detail .gallery img { width: 100%; display: block; border-radius: 10px; }
.thumbs { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.thumbs img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 2px solid transparent; cursor: pointer; opacity: .65; transition: opacity .15s; }
.thumbs img.on { border-color: var(--brand); opacity: 1; }
.p-summary { color: var(--muted); line-height: 1.75; margin: 12px 0; }
.sub-title { margin: 18px 0 0; font-size: 15px; }
.buy-actions { display: flex; align-items: center; gap: 12px; margin-top: 20px; flex-wrap: wrap; }
.buy-actions .qty { display: flex; align-items: center; gap: 8px; }
.buy-actions .qty button { width: 30px; height: 30px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font-size: 16px; }
.buy-actions .qty span { min-width: 26px; text-align: center; }
.detail-rich { margin-top: 38px; padding-top: 26px; border-top: 1px solid var(--line); }
.rich-title { margin: 0 0 16px; font-size: 20px; }
.specs { width: 100%; border-collapse: collapse; margin-top: 12px; }
.specs td { padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 14px; }
.specs td:first-child { color: var(--muted); width: 120px; }
.priceline { font-size: 26px; font-weight: 800; color: var(--brand-2); margin: 6px 0; }
.priceline .old { color: var(--muted); font-size: 15px; font-weight: 500; text-decoration: line-through; margin-left: 8px; }
.tag { display: inline-block; font-size: 11px; background: #f3eefe; color: var(--brand); padding: 3px 8px; border-radius: 6px; margin: 0 4px 4px 0; }

/* Cart / Orders */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); margin: 18px 0; }
.line-item { display: flex; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.line-item img { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; background: #f3f3f8; }
.line-item .info { flex: 1; }
.line-item .qty { display: flex; align-items: center; gap: 8px; }
.line-item .qty button { width: 28px; height: 28px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; font-size: 16px; }
.summary { font-size: 15px; }
.summary .total { font-size: 22px; font-weight: 800; color: var(--brand-2); }
.status { font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 600; }
.status.pending { background: #fef3c7; color: #92400e; }
.status.paid { background: #dcfce7; color: #166534; }
.status.shipped { background: #dbeafe; color: #1e40af; }
.status.completed { background: #ede9fe; color: #5b21b6; }

/* Misc */
.empty { text-align: center; color: var(--muted); padding: 60px 0; }
.section-title { margin: 26px 0 12px; font-size: 18px; }
.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); background: #1f2330; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; opacity: 0; transition: opacity .2s; z-index: 200; pointer-events: none; }
.toast.show { opacity: 1; }
.muted { color: var(--muted); }
.center { text-align: center; }
.footer { text-align: center; color: var(--muted); font-size: 13px; padding: 30px 0; }

/* Admin */
.admin-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.admin-table th, .admin-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.admin-table img { width: 44px; height: 44px; object-fit: cover; border-radius: 8px; }

@media (max-width: 760px) {
  .detail-top { grid-template-columns: 1fr; }
  .nav span.hide-sm { display: none; }
  .rich-title { font-size: 17px; }
}

/* 富文本介绍排版（商品详情页下方全宽区） */
.rich-text { font-size: 15px; line-height: 1.85; color: #2b2b34; }
.rich-text > *:first-child { margin-top: 0; }
.rich-text h1, .rich-text h2, .rich-text h3, .rich-text h4 { line-height: 1.45; margin: 26px 0 12px; color: #1c1c22; }
.rich-text h1 { font-size: 24px; }
.rich-text h2 { font-size: 20px; }
.rich-text h3 { font-size: 17px; }
.rich-text h4 { font-size: 15px; }
.rich-text p { margin: 0 0 14px; }
.rich-text ul, .rich-text ol { margin: 0 0 16px; padding-left: 24px; }
.rich-text li { margin-bottom: 6px; }
.rich-text blockquote { margin: 16px 0; padding: 10px 16px; border-left: 4px solid var(--brand); background: #f8f5ff; color: #555; border-radius: 0 8px 8px 0; }
.rich-text img { max-width: 100%; height: auto; display: block; margin: 16px auto; border-radius: 10px; }
.rich-text figure { margin: 20px 0; text-align: center; }
.rich-text figcaption { font-size: 13px; color: var(--muted); margin-top: 8px; }
.rich-text a { color: var(--brand); }
.rich-text hr { border: none; border-top: 1px solid var(--line); margin: 24px 0; }
.rich-text table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; }
.rich-text th, .rich-text td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.rich-text th { background: #faf8ff; }
.rich-text code { background: #f4f2f7; padding: 2px 6px; border-radius: 5px; font-size: 13px; }
.rich-text pre { background: #f4f2f7; padding: 12px 14px; border-radius: 8px; overflow-x: auto; }

/* 后台富文本编辑器 */
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 6px; border: 1px solid var(--line); border-bottom: none; border-radius: 10px 10px 0 0; background: #faf8ff; }
.editor-toolbar button { border: 1px solid transparent; background: #fff; border-radius: 7px; padding: 5px 9px; font-size: 13px; cursor: pointer; color: #444; line-height: 1.2; }
.editor-toolbar button:hover { border-color: var(--brand); color: var(--brand); }
.tb-sep { width: 1px; height: 18px; background: var(--line); margin: 0 4px; }
.rich-editor { min-height: 190px; max-height: 520px; overflow-y: auto; padding: 12px 14px; border: 1px solid var(--line); border-radius: 0 0 10px 10px; background: #fff; outline: none; line-height: 1.8; font-size: 14px; }
.rich-editor:focus { border-color: var(--brand); }
.rich-editor:empty::before { content: attr(data-placeholder); color: #aaa; }
.rich-editor img { max-width: 100%; height: auto; border-radius: 8px; margin: 8px 0; }
.rich-editor figure { margin: 12px 0; }
.rich-editor h2 { font-size: 19px; margin: 14px 0 8px; }
.rich-editor h3 { font-size: 16px; margin: 12px 0 6px; }
.rich-editor blockquote { margin: 10px 0; padding: 8px 14px; border-left: 4px solid var(--brand); background: #f8f5ff; }
.rich-editor ul, .rich-editor ol { padding-left: 24px; }

/* 后台主图列表 */
.img-list { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-start; }
.img-item { width: 88px; }
.img-item img { width: 88px; height: 88px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); display: block; background: #f6f6fb; }
.img-ops { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 5px; }
.img-ops button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 1px 6px; font-size: 12px; cursor: pointer; }
.img-ops button:hover { border-color: var(--brand); color: var(--brand); }
.cover-tag { font-size: 11px; color: var(--brand); border: 1px solid var(--brand); border-radius: 6px; padding: 1px 6px; }

/* Header mini selects */
select.mini { padding: 5px 8px; border-radius: 8px; border: 1px solid var(--line); background: #fff; font-size: 12px; color: var(--muted); cursor: pointer; }

/* 后台通用：链接按钮 / 已连接状态条 / 分页 / 草稿提示 / 订单详情栅格 */
a.btn { text-decoration: none; }
.admin-table a { color: var(--brand); text-decoration: none; }
.admin-table a:hover { text-decoration: underline; }
.conn-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 14px; background: #f2faf4; border: 1px solid #cfe8d6; border-radius: 10px; font-size: 13px; color: #2f6b41; }
.conn-bar .conn-right { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.conn-bar .btn, .pager .btn, .draft-tip .btn { padding: 5px 11px; font-size: 13px; }
.draft-tip { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 9px 14px; margin-bottom: 14px; background: #fff8e6; border: 1px solid #f1dda6; border-radius: 10px; font-size: 13px; color: #8a6212; }
.pager { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.pager-info { font-size: 13px; color: var(--muted); }
.order-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 28px; }
.order-grid .sub-title { margin-top: 16px; }
@media (max-width: 760px) { .order-grid { grid-template-columns: 1fr; } }

/* Legal footer */
.legal-footer { background: #15171f; color: #c9ccd6; margin-top: 40px; padding: 22px 0; font-size: 13px; }
.legal-footer .container { display: flex; flex-direction: column; gap: 10px; }
.lf-links { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.lf-links a { color: #c9ccd6; }
.lf-links a:hover { color: #fff; }
.lf-links span { color: #4b4f5e; }
.lf-social { display: flex; gap: 14px; }
.lf-social a { color: var(--brand); }
.lf-copy { color: #7a7e8c; font-size: 12px; }

/* Cookie consent */
.cookie-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 300; display: flex; justify-content: center; padding: 14px; background: rgba(21,23,31,.55); backdrop-filter: blur(2px); }
.cookie-box { background: #fff; border-radius: 14px; padding: 18px 20px; max-width: 560px; width: 100%; box-shadow: var(--shadow); }
.cookie-box h4 { margin: 0 0 6px; }
.cookie-box p { margin: 0 0 10px; color: var(--muted); font-size: 13px; }
.cookie-box .ck { display: block; font-size: 13px; margin: 6px 0; }
.cookie-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }

/* Chat widget */
.chat-fab { position: fixed; right: 18px; bottom: 18px; width: 52px; height: 52px; border-radius: 50%; border: none; background: var(--brand); color: #fff; font-size: 22px; cursor: pointer; box-shadow: 0 8px 24px rgba(124,58,237,.4); z-index: 250; }
.chat-panel { position: fixed; right: 18px; bottom: 80px; width: 300px; max-width: 92vw; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); z-index: 250; display: flex; flex-direction: column; overflow: hidden; }
.chat-head { background: var(--brand); color: #fff; padding: 10px 12px; font-size: 13px; font-weight: 600; }
.chat-body { flex: 1; max-height: 240px; overflow-y: auto; padding: 10px; font-size: 13px; }
.chat-msg { padding: 7px 10px; border-radius: 10px; margin-bottom: 8px; max-width: 85%; }
.chat-msg.bot { background: #f3eefe; color: var(--ink); }
.chat-msg.me { background: var(--brand); color: #fff; margin-left: auto; }
.chat-form { display: flex; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; border: none; padding: 10px; outline: none; font-size: 13px; }
.chat-form button { border: none; background: var(--brand); color: #fff; padding: 0 14px; cursor: pointer; }

/* Legal page */
.legal-nav { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.legal-nav a { padding: 6px 12px; border: 1px solid var(--line); border-radius: 999px; font-size: 13px; color: var(--muted); }
.legal-nav a.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.legal-doc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.legal-doc h2 { margin-top: 0; }
.legal-doc h3 { margin: 18px 0 6px; }
.legal-doc ul { padding-left: 20px; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px; margin: 0 4px 4px 0; }
.badge.ce { background: #dbeafe; color: #1e40af; }
.badge.weee { background: #dcfce7; color: #166534; }
.badge.en71 { background: #fef3c7; color: #92400e; }
.badge.age { background: #ede9fe; color: #5b21b6; }
.badge.batt { background: #fee2e2; color: #991b1b; }

/* Invoice */
.invoice { max-width: 720px; margin: 20px auto; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 28px; }
.invoice h1 { margin: 0 0 4px; }
.inv-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
@media print { header.site, .legal-footer, .chat-fab, .chat-panel, .no-print { display: none !important; } .invoice { border: none; } }

/* Shipping / tariff */
.calc { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.calc .field { margin-bottom: 10px; }
