:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #18201d;
  background: #f4f6f5;
  font-synthesis: none;
  --ink: #18201d;
  --muted: #66716d;
  --line: #d8dedb;
  --surface: #ffffff;
  --soft: #edf1ef;
  --wechat: #087f5b;
  --wechat-dark: #066748;
  --accent: #d84d35;
  --accent-dark: #b83c29;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #f4f6f5; color: var(--ink); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid #78b9a3; outline-offset: 2px; }
img { max-width: 100%; }

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

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 46px;
  padding: 11px 18px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 720;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}
.button svg { width: 19px; height: 19px; }
.button:disabled { cursor: not-allowed; opacity: .45; }
.button--primary { background: var(--ink); color: #fff; }
.button--primary:hover { background: #303936; }
.button--wechat { width: 100%; background: var(--wechat); color: #fff; }
.button--wechat:hover { background: var(--wechat-dark); }
.button--wechat.button--preferred { box-shadow: 0 0 0 3px rgba(8, 127, 91, .16); }
.button--quiet { width: 100%; border-color: var(--line); background: var(--surface); color: var(--ink); }
.button--accent { width: 100%; background: var(--accent); color: #fff; }
.button--accent:hover { background: var(--accent-dark); }

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
}
.icon-button:hover { background: var(--soft); }
.icon-button svg { width: 18px; height: 18px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-weight: 850;
  font-size: 19px;
}
.brand-mark--small { width: 34px; height: 34px; font-size: 12px; }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 12px; font-weight: 800; text-transform: uppercase; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-panel {
  width: min(100%, 400px);
  padding: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}
.auth-panel .brand-mark { margin-bottom: 28px; }
.auth-panel h1 { margin: 0 0 28px; font-size: 30px; line-height: 1.2; letter-spacing: 0; }
.auth-actions { display: grid; gap: 12px; }
.auth-actions form { margin: 0; }
.alert { padding: 11px 12px; border-radius: 6px; font-size: 14px; }
.alert--error { border: 1px solid #e6a99f; background: #fff3f1; color: #962f20; }
.config-note { margin: 16px 0 0; color: var(--muted); font-size: 13px; text-align: center; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 64px;
  padding: 10px max(18px, calc((100vw - 1120px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.header-actions form { display: flex; margin: 0; }
.user-name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 14px; }

.page-shell { width: min(1120px, calc(100% - 36px)); margin: 0 auto; }
.catalog-page { padding: 52px 0 72px; }
.page-heading { margin-bottom: 24px; }
.page-heading h1, .editor-heading h1 { margin: 0; font-size: 30px; line-height: 1.2; letter-spacing: 0; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 340px)); gap: 18px; }
.product-card {
  display: block;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
  transition: border-color .16s ease, transform .16s ease;
}
.product-card:hover { border-color: #9ca7a2; transform: translateY(-2px); }
.product-card__media { aspect-ratio: 4 / 3; overflow: hidden; background: #e7eae8; }
.product-card__media img { display: block; width: 100%; height: 100%; object-fit: cover; }
.product-card__body { padding: 18px; }
.product-card h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: 0; }
.product-card p { margin: 0; color: var(--muted); font-size: 14px; }
.product-meta { display: flex; gap: 18px; margin: 18px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
.product-meta div { display: grid; gap: 3px; }
.product-meta dt { color: var(--muted); font-size: 11px; }
.product-meta dd { margin: 0; font-size: 13px; font-weight: 700; }

.editor-page { display: grid; grid-template-columns: minmax(0, 1fr) 340px; min-height: calc(100vh - 65px); }
.editor-workspace { min-width: 0; padding: 34px clamp(18px, 4vw, 54px) 48px; }
.editor-heading { width: min(720px, 100%); margin: 0 auto 20px; }
.upload-state {
  position: relative;
  display: grid;
  place-items: center;
  width: min(720px, 100%);
  aspect-ratio: 1 / 1;
  min-height: 360px;
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #e7eae8;
}
.upload-state::after { content: ""; position: absolute; inset: 0; background: rgba(16, 25, 22, .32); }
.upload-state img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.upload-state .button { position: relative; z-index: 1; }
.crop-workspace { width: min(720px, 100%); margin: 0 auto; }
.crop-stage {
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 360px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1d2422;
}
.crop-stage > img { display: block; max-width: 100%; }
.crop-toolbar {
  display: grid;
  grid-template-columns: 40px minmax(120px, 1fr) 40px 40px 40px;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.crop-toolbar input[type="range"] { width: 100%; accent-color: var(--accent); }

.order-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 36px 28px;
  border-left: 1px solid var(--line);
  background: var(--surface);
}
.panel-label { display: block; margin-bottom: 12px; color: var(--muted); font-size: 12px; font-weight: 700; }
.badge-preview {
  position: relative;
  width: min(210px, 100%);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  overflow: hidden;
  border: 8px solid #d7d9d8;
  border-radius: 50%;
  background: var(--soft);
  box-shadow: 0 3px 0 #a9afac;
}
.product-preview__content { width: 100%; height: 100%; overflow: hidden; }
.product-preview__content img { max-width: none; }
.order-summary { display: grid; gap: 12px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.order-summary div { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; }
.order-summary span { color: var(--muted); }
.order-summary strong { text-align: right; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; cursor: pointer; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle {
  position: relative;
  flex: 0 0 44px;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: #aeb7b3;
  transition: background .16s ease;
}
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .16s ease; }
.toggle-row input:checked + .toggle { background: var(--wechat); }
.toggle-row input:checked + .toggle::after { transform: translateX(20px); }
.toggle-row input:focus-visible + .toggle { outline: 3px solid #78b9a3; outline-offset: 2px; }
.print-status { display: grid; grid-template-columns: 10px 1fr; gap: 10px; align-items: start; padding-top: 4px; }
.status-dot { width: 10px; height: 10px; margin-top: 5px; border-radius: 50%; background: #9aa39f; }
.print-status[data-tone="success"] .status-dot { background: var(--wechat); }
.print-status[data-tone="error"] .status-dot { background: var(--accent); }
.print-status strong { font-size: 14px; }
.print-status p { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }

.cropper-view-box, .cropper-face { border-radius: 0; }
.cropper-view-box { outline: 2px solid #fff; outline-color: rgba(255, 255, 255, .95); }
.cropper-line, .cropper-point { display: none; }
.cropper-modal { opacity: .58; background: #0e1412; }

@media (max-width: 820px) {
  .editor-page { grid-template-columns: 1fr; }
  .editor-workspace { padding-bottom: 28px; }
  .order-panel { border-top: 1px solid var(--line); border-left: 0; padding: 28px 20px 36px; }
  .preview-block { display: grid; grid-template-columns: 1fr 150px; align-items: center; gap: 18px; }
  .preview-block .panel-label { margin: 0; font-size: 14px; }
  .badge-preview { width: 150px; }
}

@media (max-width: 520px) {
  .auth-shell { padding: 0; place-items: stretch; }
  .auth-panel { min-height: 100vh; padding: 32px 22px; border: 0; border-radius: 0; }
  .site-header { padding: 10px 14px; }
  .brand strong, .user-name { display: none; }
  .catalog-page { padding-top: 34px; }
  .product-grid { grid-template-columns: 1fr; }
  .editor-workspace { padding: 24px 14px; }
  .page-heading h1, .editor-heading h1 { font-size: 26px; }
  .upload-state, .crop-stage { min-height: 0; }
  .crop-toolbar { grid-template-columns: 40px minmax(80px, 1fr) 40px 40px 40px; gap: 5px; }
  .preview-block { grid-template-columns: 1fr 118px; }
  .badge-preview { width: 118px; border-width: 6px; }
}
