/* ===========================================================================
   冠宇全球网络服务 - design system (Apple-ish, mobile first)
   See docs/DESIGN-SYSTEM.md
   =========================================================================== */
:root {
  --bg: #f5f5f7;
  --surface: #ffffff;
  --surface-2: #fafafc;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --border: #d2d2d7;
  --border-soft: #e8e8ed;
  --primary: #0071e3;
  --primary-hover: #0077ed;
  --primary-soft: #eaf4ff;
  --success: #2e7d4f;
  --success-soft: #eef7f1;
  --warning: #b26a00;
  --warning-soft: #fff7ec;
  --danger: #c7362f;
  --danger-soft: #fdf0ef;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.06);

  --container: 1200px;
  --reading: 740px;
  --header-h: 52px;
  --focus: 0 0 0 3px rgba(0, 113, 227, 0.35);

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

/* --------------------------------------------------------------------------
   Stage 5B: storefront empty state.
   Shown when the catalogue has no public products yet (e.g. while the new
   product design is being built). Never render a blank page or a bare error.
   -------------------------------------------------------------------------- */
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  padding: 52px 24px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}
.empty-state__icon { font-size: 44px; line-height: 1; margin-bottom: 6px; }
.empty-state__title { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; }
.empty-state__text { margin: 0; color: var(--text-secondary); font-size: 15px; max-width: 420px; }
.empty-state__hint { margin-top: 12px; font-size: 13px; color: var(--text-tertiary); }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { letter-spacing: -0.02em; line-height: 1.15; margin: 0; }
img, video { max-width: 100%; display: block; }

:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 8px; }

/* ---------------------------------------------------------------- layout */
.site-header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  background: rgba(245, 245, 247, 0.82);
  backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border-soft);
}
.site-header__inner {
  max-width: var(--container); margin: 0 auto; height: 100%;
  padding: 0 16px; display: flex; align-items: center; gap: 6px;
}
.brand { font-weight: 600; font-size: 16px; color: var(--text); display: flex; align-items: center; gap: 8px; }
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 26px; height: 26px; border-radius: 8px; background: var(--text);
  color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 700;
}
.site-nav { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.site-nav a {
  color: var(--text); font-size: 14.5px; padding: 8px 12px; border-radius: 10px; min-height: 44px;
  display: inline-flex; align-items: center;
}
.site-nav a:hover { background: rgba(0,0,0,0.045); text-decoration: none; }
.site-nav a.is-active { color: var(--primary); }

.container { max-width: var(--container); margin: 0 auto; padding: 20px 16px 96px; }
.reading { max-width: var(--reading); margin: 0 auto; }

.site-footer {
  border-top: 1px solid var(--border-soft); margin-top: 40px;
  padding: 24px 16px 40px; color: var(--text-tertiary); font-size: 13px; text-align: center;
}

/* ------------------------------------------------------------------ hero */
.hero { padding: 44px 0 30px; text-align: center; }
.hero h1 { font-size: clamp(28px, 6vw, 44px); font-weight: 700; }
.hero p { color: var(--text-secondary); font-size: 17px; margin: 12px auto 0; max-width: 560px; }
.hero__points { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 18px; }
.hero__point {
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: 999px;
  padding: 7px 14px; font-size: 13.5px; color: var(--text-secondary);
}

/* ------------------------------------------------------------------ cards */
.card {
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 14px; }
.card__title { font-size: 17px; font-weight: 600; margin-bottom: 6px; }
.section { margin: 28px 0; }
.section__head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.section__head h2 { font-size: 22px; }
.section__head a { margin-left: auto; font-size: 14px; }

.grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 1280px) { .grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

.product-card {
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-lg);
  overflow: hidden; display: flex; flex-direction: column; color: inherit;
}
.product-card:hover { text-decoration: none; box-shadow: var(--shadow); }
.product-card__media {
  aspect-ratio: 4 / 3; background: linear-gradient(180deg, #fbfbfd, #f0f0f4);
  display: grid; place-items: center; color: var(--text-tertiary); font-size: 26px;
}
.product-card__media img { width: 100%; height: 100%; object-fit: cover; }
.product-card__body { padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 6px; }
.product-card__title { font-size: 15.5px; font-weight: 600; }
.product-card__meta { font-size: 13px; color: var(--text-secondary); }
.price { color: var(--text); font-weight: 600; font-size: 17px; }
.price--accent { color: var(--primary); }
.price s { color: var(--text-tertiary); font-weight: 400; font-size: 13px; margin-left: 6px; }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 20px; border-radius: var(--radius);
  border: 1px solid transparent; background: var(--primary); color: #fff;
  font: inherit; font-size: 16px; font-weight: 500; cursor: pointer; width: 100%;
}
.btn:hover { background: var(--primary-hover); }
.btn--ghost { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn--ghost:hover { background: var(--primary-soft); }
.btn--quiet { background: var(--surface-2); color: var(--text); border-color: var(--border-soft); }
.btn--danger { background: var(--danger); }
.btn--small { min-height: 38px; padding: 8px 12px; font-size: 14px; width: auto; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row .btn { width: auto; flex: 1 1 180px; }

/* ----------------------------------------------------------------- forms */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit; font-size: 16px;
}
.input:focus { border-color: var(--primary); outline: none; box-shadow: var(--focus); }
.field--error .input { border-color: var(--danger); }
.qty { display: inline-flex; align-items: center; gap: 8px; }
.qty button {
  width: 46px; height: 46px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); font-size: 20px; color: var(--text); cursor: pointer;
}
.qty input { width: 76px; text-align: center; }

/* ------------------------------------------------------------ sku picker */
.sku-list { display: grid; gap: 10px; }
.sku {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--surface); border: 1.5px solid var(--border-soft); border-radius: var(--radius-lg);
  padding: 14px 16px; min-height: 64px; cursor: pointer; width: 100%; font: inherit; color: inherit;
}
.sku:hover { border-color: var(--border); }
.sku.is-selected { border-color: var(--primary); background: var(--primary-soft); }
.sku__main { flex: 1; min-width: 0; }
.sku__name { font-weight: 600; font-size: 15.5px; }
.sku__sub { font-size: 13px; color: var(--text-secondary); }
.sku__side { text-align: right; white-space: nowrap; }
.sku__stock { font-size: 12.5px; color: var(--text-tertiary); }
.sku.is-disabled { opacity: 0.55; cursor: not-allowed; }

/* ----------------------------------------------------------- status etc. */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500; background: var(--surface-2); color: var(--text-secondary);
}
.badge--pending { background: var(--warning-soft); color: var(--warning); }
.badge--paid, .badge--fulfilling { background: var(--primary-soft); color: var(--primary); }
.badge--completed { background: var(--success-soft); color: var(--success); }
.badge--expired, .badge--cancelled, .badge--failed { background: var(--surface-2); color: var(--text-secondary); }
.badge--refunded { background: #f2eefc; color: #5b21b6; }

.alert { border-radius: var(--radius); padding: 12px 14px; font-size: 14px; margin: 12px 0; border: 1px solid transparent; }
.alert--info { background: var(--primary-soft); color: #0b4a8f; }
.alert--success { background: var(--success-soft); color: var(--success); }
.alert--warning { background: var(--warning-soft); color: var(--warning); }
.alert--danger { background: var(--danger-soft); color: var(--danger); }

.muted { color: var(--text-secondary); font-size: 13.5px; }
.tertiary { color: var(--text-tertiary); font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13.5px; word-break: break-all; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 10px; }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--border-soft); font-size: 14.5px; }
.kv:last-child { border-bottom: none; }
.kv > span:first-child { color: var(--text-secondary); }
.kv > span:last-child { text-align: right; }

/* ------------------------------------------------------------- secret box */
.secret {
  background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius);
  padding: 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px; white-space: pre-wrap; word-break: break-all; margin-bottom: 10px;
}

/* -------------------------------------------------------------- buy bar */
.buy-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(255, 255, 255, 0.92); backdrop-filter: blur(18px);
  border-top: 1px solid var(--border-soft);
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 12px;
}
.buy-bar__price { font-size: 13px; color: var(--text-secondary); }
.buy-bar__price b { display: block; font-size: 18px; color: var(--text); }
.buy-bar .btn { width: auto; flex: 1; max-width: 260px; }

/* ---------------------------------------------------------------- modal */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 18px; background: rgba(0,0,0,0.35); }
.modal__panel {
  background: var(--surface); border-radius: var(--radius-xl); width: 100%; max-width: 520px;
  max-height: 86vh; overflow: auto; padding: 22px; box-shadow: var(--shadow);
}
.modal__head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 10px; }
.modal__close {
  margin-left: auto; width: 44px; height: 44px; border-radius: 999px; border: none;
  background: var(--surface-2); color: var(--text-secondary); font-size: 18px; cursor: pointer;
}

/* ----------------------------------------------------------------- chat */
.chat-launcher {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 50;
  background: var(--text); color: #fff; border: none; border-radius: 999px;
  padding: 12px 18px; font: inherit; font-size: 15px; min-height: 48px; cursor: pointer;
  box-shadow: var(--shadow);
}
.chat-panel {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 55;
  width: 360px; max-width: calc(100vw - 32px); height: 520px; max-height: 76vh;
  background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius-xl);
  display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow);
}
.chat-panel__head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border-soft); }
.chat-panel__body { flex: 1; overflow: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; background: var(--surface-2); }
.chat-panel__foot { border-top: 1px solid var(--border-soft); padding: 10px 12px; display: flex; gap: 8px; align-items: flex-end; }
.chat-msg { max-width: 84%; padding: 10px 13px; border-radius: 16px; font-size: 14.5px; white-space: pre-wrap; }
.chat-msg--customer { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 6px; }
.chat-msg--agent { align-self: flex-start; background: var(--surface); border: 1px solid var(--border-soft); }
.chat-msg--system, .chat-msg--contact_card { align-self: center; background: var(--surface); border: 1px dashed var(--border); color: var(--text-secondary); font-size: 13.5px; max-width: 92%; }
@media (max-width: 639px) {
  .chat-panel { right: 0; left: 0; bottom: 0; width: 100%; max-width: none; height: 88vh; max-height: 88vh; border-radius: var(--radius-xl) var(--radius-xl) 0 0; }
}

/* ------------------------------------------------------------ tutorials */
.tutorial-media { border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border-soft); margin: 14px 0; }
.tutorial-media video { width: 100%; max-height: 60vh; background: #000; }
.tutorial-body { max-width: var(--reading); font-size: 16.5px; }
.tutorial-body h2 { font-size: 22px; margin: 26px 0 10px; }
.tutorial-body h3 { font-size: 18px; margin: 20px 0 8px; }
.tutorial-body p { margin: 12px 0; }
.tutorial-body img { border-radius: var(--radius); margin: 14px 0; }
.steps { counter-reset: step; padding: 0; list-style: none; }
.steps li { position: relative; padding-left: 40px; margin: 14px 0; }
.steps li::before {
  counter-increment: step; content: counter(step);
  position: absolute; left: 0; top: 2px; width: 26px; height: 26px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-size: 13px; font-weight: 600;
}

/* -------------------------------------------------------------- spinner */
.spinner { text-align: center; color: var(--text-tertiary); padding: 40px 0; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 80;
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px;
}
.hidden { display: none !important; }
