/* 窦窦美术家长自助购买平台 —— 统一样式 */

:root {
  --bg: #ffffff;
  --bg-soft: #f7f6f3;
  --bg-sink: #f1efe9;
  --line: #e7e4dd;
  --line-strong: #d6d2c8;
  --ink: #1a1b1d;
  --ink-2: #5c5e63;
  --ink-3: #8e9096;
  --brand: #2f5a4c;
  --brand-hover: #26493e;
  --brand-soft: #eaf0ed;
  --warn: #b4552b;
  --warn-soft: #fbf1e9;
  --r: 12px;
  --r-sm: 8px;
  --r-pill: 999px;
  --head-h: 60px;
  --shadow: 0 1px 2px rgba(26, 27, 29, .04), 0 8px 24px rgba(26, 27, 29, .06);
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
}

* { box-sizing: border-box; }

/* hidden 属性必须压过组件自身的 display:flex/grid */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

body.is-locked { overflow: hidden; }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
img { display: block; max-width: 100%; }

.ic {
  width: 20px; height: 20px;
  flex: none;
  stroke: currentColor;
  fill: none;
  vertical-align: middle;
}
.ic-sm { width: 16px; height: 16px; }
.ic-lg { width: 24px; height: 24px; }

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

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------- 顶栏 ---------- */

.site-head {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}

.head-inner {
  height: var(--head-h);
  display: flex; align-items: center; gap: 16px;
}

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

.brand-mark {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--brand);
  background: var(--bg);
}

.brand-name {
  font-size: 15px; font-weight: 650; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-sub { display: block; font-size: 11px; font-weight: 400; color: var(--ink-3); letter-spacing: .4px; }

.head-search { flex: 1; max-width: 420px; margin-left: auto; }

.field {
  display: flex; align-items: center; gap: 8px;
  height: 38px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--bg-soft);
  color: var(--ink-3);
  transition: border-color .15s, background .15s;
}
.field:focus-within { border-color: var(--brand); background: var(--bg); color: var(--brand); }
.field input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: none;
  font: inherit; color: var(--ink);
}
.field input::placeholder { color: var(--ink-3); }

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

.icon-btn {
  position: relative;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--bg);
  transition: border-color .15s, background .15s;
}
.icon-btn:hover { border-color: var(--line-strong); background: var(--bg-soft); }

.cart-btn {
  width: auto; padding: 0 14px 0 12px; gap: 8px;
  display: flex; align-items: center;
  font-size: 14px; font-weight: 600;
}

.badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 18px; height: 18px; padding: 0 5px;
  display: grid; place-items: center;
  border-radius: var(--r-pill);
  background: var(--brand); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
}

.mobile-search { display: none; padding: 0 20px 12px; }

/* ---------- Hero ---------- */

.hero { border-bottom: 1px solid var(--line); background: var(--bg-soft); }
.hero-inner { padding: 34px 0 30px; }
.hero h1 { margin: 0 0 8px; font-size: 26px; line-height: 1.35; letter-spacing: -.2px; }
.hero p { margin: 0; max-width: 620px; color: var(--ink-2); font-size: 14px; }

.hero-points {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 18px; padding: 0; list-style: none;
}
.hero-points li {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  background: var(--bg);
  font-size: 13px; color: var(--ink-2);
}
.hero-points .ic { color: var(--brand); }

/* ---------- 分类条 ---------- */

.cat-bar {
  position: sticky; top: var(--head-h); z-index: 30;
  background: rgba(255, 255, 255, .94);
  backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.cat-scroll {
  display: flex; gap: 8px;
  padding: 12px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.cat-scroll::-webkit-scrollbar { display: none; }

.chip {
  display: flex; align-items: center; gap: 6px;
  flex: none;
  height: 34px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--bg);
  font-size: 13.5px; font-weight: 500; color: var(--ink-2);
  white-space: nowrap;
  transition: all .15s;
}
.chip:hover { border-color: var(--line-strong); color: var(--ink); }
.chip[aria-pressed="true"] {
  background: var(--brand); border-color: var(--brand); color: #fff;
}
.chip .ic { width: 15px; height: 15px; }

/* ---------- 工具条 ---------- */

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 20px 0 14px;
}
.result-count { font-size: 13px; color: var(--ink-3); }
.result-count b { color: var(--ink); font-weight: 650; }

.sort {
  display: flex; align-items: center; gap: 6px;
  height: 34px; padding: 0 10px 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--bg); font-size: 13px; color: var(--ink-2);
}
.sort select {
  border: 0; outline: 0; background: none; font: inherit; color: var(--ink);
  cursor: pointer; padding-right: 2px;
}

/* ---------- 商品网格 ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  padding-bottom: 48px;
}

.card {
  display: flex; flex-direction: column;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--bg);
  overflow: hidden;
  transition: border-color .18s, transform .18s, box-shadow .18s;
}
.card:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow); }

.card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--bg-sink);
  cursor: pointer;
  overflow: hidden;
}
.card-media img {
  width: 100%; height: 100%; object-fit: cover;
  transition: transform .4s ease;
}
.card:hover .card-media img { transform: scale(1.03); }

.tag {
  position: absolute; top: 10px; left: 10px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, .94);
  border: 1px solid var(--line-strong);
  font-size: 11.5px; font-weight: 600; color: var(--brand);
  letter-spacing: .2px;
}
.tag-hot { color: var(--warn); }

.card-body { display: flex; flex-direction: column; flex: 1; padding: 14px; gap: 6px; }

.card-name {
  margin: 0; font-size: 14.5px; font-weight: 600; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-spec {
  font-size: 12.5px; color: var(--ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.card-foot {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 10px; margin-top: auto; padding-top: 10px;
}

.price { display: flex; align-items: baseline; gap: 1px; color: var(--ink); }
.price .cur { font-size: 12.5px; font-weight: 600; margin-right: 3px; }
.price .num { font-size: 20px; font-weight: 700; letter-spacing: -.3px; }
.price .unit { font-size: 12px; color: var(--ink-3); margin-left: 3px; }

.add-btn {
  display: flex; align-items: center; gap: 5px;
  height: 34px; padding: 0 12px;
  border: 1px solid var(--brand); border-radius: var(--r-sm);
  background: var(--brand); color: #fff;
  font-size: 13px; font-weight: 600;
  transition: background .15s;
}
.add-btn:hover { background: var(--brand-hover); }
.add-btn.in-cart { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-soft); }

.empty {
  grid-column: 1 / -1;
  padding: 72px 20px; text-align: center; color: var(--ink-3);
}
.empty .ic { width: 40px; height: 40px; color: var(--line-strong); margin-bottom: 12px; }

/* ---------- 抽屉（购物车 / 详情） ---------- */

.scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(26, 27, 29, .42);
  opacity: 0; visibility: hidden;
  transition: opacity .25s, visibility .25s;
}
.scrim.open { opacity: 1; visibility: visible; }

.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 51;
  width: min(440px, 100%);
  display: flex; flex-direction: column;
  background: var(--bg);
  border-left: 1px solid var(--line);
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.32, .72, 0, 1);
}
.drawer.open { transform: none; }

.drawer-head {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; font-size: 16px; font-weight: 650; flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.drawer-foot { border-top: 1px solid var(--line); padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); }

.back-btn {
  display: flex; align-items: center; gap: 4px;
  font-size: 13px; color: var(--ink-2);
  background: none; border: 0; padding: 0;
}
.back-btn:hover { color: var(--ink); }

/* 购物车行 */
.line-item { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.line-item:first-child { padding-top: 0; }
.line-thumb {
  width: 68px; height: 68px; flex: none;
  border-radius: var(--r-sm); background: var(--bg-sink);
  object-fit: cover;
}
.line-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.line-name { font-size: 14px; font-weight: 600; line-height: 1.4; }
.line-spec { font-size: 12px; color: var(--ink-3); }
.line-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.line-price { font-size: 14px; font-weight: 650; }

.stepper {
  display: flex; align-items: center;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  overflow: hidden;
}
.stepper button {
  width: 28px; height: 28px; display: grid; place-items: center;
  background: var(--bg); border: 0; color: var(--ink-2);
}
.stepper button:hover { background: var(--bg-soft); color: var(--ink); }
.stepper span { min-width: 30px; text-align: center; font-size: 13px; font-weight: 600; }

.sum-row { display: flex; align-items: center; justify-content: space-between; font-size: 13.5px; color: var(--ink-2); }
.sum-row + .sum-row { margin-top: 6px; }
.sum-total { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); font-size: 15px; color: var(--ink); }
.sum-total b { font-size: 21px; font-weight: 700; }

.btn {
  width: 100%; height: 46px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--brand); border-radius: var(--r-sm);
  background: var(--brand); color: #fff;
  font-size: 15px; font-weight: 600;
  transition: background .15s;
}
.btn:hover { background: var(--brand-hover); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: var(--bg); color: var(--ink); border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--bg-soft); }
.btn-sm { height: 38px; font-size: 14px; width: auto; padding: 0 16px; }

/* 表单 */
.form-row { margin-bottom: 16px; }
.form-row label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; }
.form-row label .req { color: var(--warn); margin-left: 2px; }
.input, textarea.input, select.input {
  width: 100%; height: 42px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--bg); font: inherit; color: var(--ink);
  outline: 0; transition: border-color .15s;
}
.input:focus { border-color: var(--brand); }
textarea.input { height: 76px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
select.input { cursor: pointer; }
.hint { margin-top: 5px; font-size: 12px; color: var(--ink-3); }
.err { margin-top: 5px; font-size: 12px; color: var(--warn); display: none; }
.form-row.invalid .input { border-color: var(--warn); }
.form-row.invalid .err { display: block; }

.pill-picks { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pill-picks button {
  padding: 5px 11px; border: 1px solid var(--line); border-radius: var(--r-pill);
  background: var(--bg); font-size: 12.5px; color: var(--ink-2);
}
.pill-picks button:hover { border-color: var(--brand); color: var(--brand); }

/* 详情抽屉 */
.detail-media { aspect-ratio: 4 / 3; border-radius: var(--r); overflow: hidden; background: var(--bg-sink); }
.detail-media img { width: 100%; height: 100%; object-fit: cover; }
.detail-title { margin: 16px 0 6px; font-size: 19px; font-weight: 650; line-height: 1.4; }
.detail-spec { font-size: 13px; color: var(--ink-3); }
.detail-desc { margin: 14px 0 0; font-size: 14px; color: var(--ink-2); line-height: 1.75; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.detail-tags span {
  padding: 4px 10px; border-radius: var(--r-pill);
  background: var(--brand-soft); color: var(--brand);
  font-size: 12px; font-weight: 500;
}

/* ---------- 页脚 ---------- */

.site-foot { border-top: 1px solid var(--line); background: var(--bg-soft); }
.foot-inner {
  padding: 28px 0;
  display: flex; flex-wrap: wrap; gap: 16px 32px;
  align-items: flex-start; justify-content: space-between;
  font-size: 12.5px; color: var(--ink-3);
}
.foot-inner p { margin: 0 0 4px; }
.foot-links { display: flex; gap: 16px; }
.foot-links a:hover { color: var(--ink); }

/* ---------- 提示条 ---------- */

.toast {
  position: fixed; left: 50%; bottom: 28px; z-index: 80;
  transform: translate(-50%, 16px);
  display: flex; align-items: center; gap: 8px;
  max-width: calc(100% - 40px);
  padding: 11px 16px;
  border-radius: var(--r-sm);
  background: var(--ink); color: #fff;
  font-size: 13.5px;
  opacity: 0; visibility: hidden;
  transition: opacity .2s, transform .2s, visibility .2s;
}
.toast.show { opacity: 1; visibility: visible; transform: translate(-50%, 0); }
.toast .ic { color: #fff; }

/* ---------- 支付页 / 订单页 ---------- */

.panel {
  max-width: 560px; margin: 40px auto 64px;
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--bg); overflow: hidden;
}
.panel-head { padding: 22px 24px; border-bottom: 1px solid var(--line); }
.panel-head h1 { margin: 0 0 4px; font-size: 19px; font-weight: 650; }
.panel-head p { margin: 0; font-size: 13px; color: var(--ink-3); }
.panel-body { padding: 22px 24px; }

.kv { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; font-size: 13.5px; }
.kv + .kv { border-top: 1px solid var(--line); }
.kv dt { color: var(--ink-3); flex: none; }
.kv dd { margin: 0; text-align: right; color: var(--ink); word-break: break-all; }

.amount { text-align: center; padding: 22px 0 26px; }
.amount .num { font-size: 38px; font-weight: 700; letter-spacing: -1px; }
.amount .cur { font-size: 20px; font-weight: 600; margin-right: 5px; }
.amount .cap { font-size: 13px; color: var(--ink-3); margin-top: 4px; }

.pay-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.pay-pick {
  display: flex; align-items: center; gap: 8px;
  padding: 13px 14px;
  border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--bg); font-size: 14px; font-weight: 500;
  transition: all .15s;
}
.pay-pick[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }

.notice {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 13px 14px; margin-bottom: 18px;
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  background: var(--bg-soft);
  font-size: 13px; color: var(--ink-2); line-height: 1.6;
}
.notice .ic { color: var(--ink-3); margin-top: 2px; }
.notice.warn { background: var(--warn-soft); border-color: #eccdb8; }
.notice.warn .ic { color: var(--warn); }

.status-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: var(--r-pill);
  font-size: 12px; font-weight: 600;
  background: var(--bg-sink); color: var(--ink-2);
}
.status-pending { background: var(--warn-soft); color: var(--warn); }
.status-paid { background: var(--brand-soft); color: var(--brand); }
.status-shipped { background: #e8eef5; color: #2f4f73; }
.status-cancelled { background: var(--bg-sink); color: var(--ink-3); }

/* ---------- 订单管理 ---------- */

.admin-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 18px 0; border-bottom: 1px solid var(--line);
}
.admin-bar .field { height: 36px; max-width: 260px; flex: 1; }
.admin-stats { display: flex; gap: 8px; flex-wrap: wrap; margin-left: auto; }
.stat {
  padding: 5px 12px; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--bg); font-size: 12.5px; color: var(--ink-3);
}
.stat b { color: var(--ink); font-size: 14px; font-weight: 700; margin-left: 4px; }

.table-wrap { overflow-x: auto; padding-bottom: 40px; }
table.orders { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 900px; }
table.orders th, table.orders td { padding: 12px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
table.orders th { font-size: 12px; font-weight: 600; color: var(--ink-3); white-space: nowrap; background: var(--bg-soft); position: sticky; top: 0; }
table.orders tbody tr:hover { background: var(--bg-soft); }
.o-no { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.o-items { color: var(--ink-2); line-height: 1.7; }
.o-items i { font-style: normal; color: var(--ink-3); }

@media (max-width: 1080px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 760px) {
  body { font-size: 14.5px; }
  .wrap { padding: 0 16px; }
  .head-search { display: none; }
  .mobile-search { display: block; }
  .brand-sub { display: none; }
  .cart-btn span.label { display: none; }
  .cart-btn { width: 38px; padding: 0; justify-content: center; }
  .hero-inner { padding: 24px 0 22px; }
  .hero h1 { font-size: 21px; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .card-body { padding: 11px; gap: 4px; }
  .card-name { font-size: 13.5px; }
  .card-spec { font-size: 11.5px; }
  .price .num { font-size: 17px; }
  .add-btn { height: 31px; padding: 0 9px; font-size: 12px; }
  .add-btn span { display: none; }
  .drawer { width: 100%; top: 44px; border-left: 0; border-top-left-radius: 16px; border-top-right-radius: 16px; }
  .panel { margin: 20px auto 48px; border-left: 0; border-right: 0; border-radius: 0; }
  .panel-head, .panel-body { padding-left: 16px; padding-right: 16px; }
  .toolbar { padding: 16px 0 12px; }
  .pay-picks { grid-template-columns: 1fr; }
  .admin-stats { width: 100%; margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
  .card:hover { transform: none; }
  .card:hover .card-media img { transform: none; }
}

.flip { transform: rotate(180deg); transform-origin: center; }
