:root {
  color-scheme: light;
  --ink: #1f2933;
  --muted: #667085;
  --line: #d9e1e8;
  --panel: #ffffff;
  --band: #f5f7f8;
  --accent: #0f8b8d;
  --accent-dark: #0a6e70;
  --gold: #c99231;
  --danger: #b42318;
  --shadow: 0 18px 50px rgba(31, 41, 51, 0.12);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

.hidden {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--band);
  overflow: hidden;
}

.runtime-notice {
  position: fixed;
  left: 16px;
  right: 16px;
  top: 12px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid #f5c26b;
  border-radius: 8px;
  background: #fff9e8;
  color: #7a4b00;
  box-shadow: 0 12px 34px rgba(31, 41, 51, 0.16);
  font-size: 13px;
}

.runtime-notice a {
  color: var(--accent-dark);
  font-weight: 700;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

button:hover {
  border-color: var(--accent);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  height: 100vh;
  overflow: hidden;
}

.workspace {
  height: 100vh;
  overflow: hidden;
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
}

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

.logo-shine {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: 4px;
  background: transparent;
}

.brand-lockup img {
  width: clamp(150px, 22vw, 280px);
  height: auto;
  display: block;
  object-fit: contain;
  animation: logoInkGlow 5.6s ease-in-out infinite;
}

@keyframes logoInkGlow {
  0%,
  100% {
    filter: brightness(1) contrast(1) drop-shadow(0 0 0 rgba(255, 255, 255, 0));
  }
  44% {
    filter: brightness(1.02) contrast(1.04) drop-shadow(0 0 1px rgba(255, 255, 255, 0.2));
  }
  52% {
    filter: brightness(1.16) contrast(1.1) drop-shadow(0 0 5px rgba(255, 255, 255, 0.45));
  }
  62% {
    filter: brightness(1.04) contrast(1.05) drop-shadow(0 0 2px rgba(142, 221, 255, 0.22));
  }
}

.brand-copy {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.eyebrow {
  margin: 0;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 16px;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-strip .orders-link,
.status-strip .admin-link {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
  line-height: 1.2;
}

.status-strip .orders-link {
  color: var(--accent-dark);
  border-color: #b8dddd;
  font-weight: 700;
}

.status-strip .share-link {
  color: #9a6a13;
  border-color: #ead39d;
  background: #fffaf0;
}

.status-strip .admin-link:hover,
.status-strip .orders-link:hover {
  border-color: var(--accent);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 48px;
  padding: 7px 12px 7px 7px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(31, 41, 51, 0.06);
}

.user-avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

.user-meta {
  display: grid;
  gap: 1px;
  text-align: left;
  line-height: 1.2;
}

.user-meta strong {
  color: var(--ink);
  font-size: 13px;
}

.user-meta small {
  color: var(--muted);
  font-size: 11px;
}

.quality-status {
  display: grid;
  gap: 8px;
  margin: -4px 0 16px;
}

.quality-status span {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 32px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  color: var(--muted);
  font-size: 13px;
}

.quality-status .warn {
  color: var(--danger);
  border-color: #f4b7ae;
  background: #fff8f7;
}

.preview-band {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 300px;
  gap: 22px;
  align-items: start;
}

.product-preview {
  position: relative;
  display: grid;
  place-items: center;
  min-height: calc(100vh - 120px);
  padding: 24px;
  background: linear-gradient(135deg, #edf3f3, #f9faf9 46%, #eef1f6);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.frame-stage {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: calc(100vh - 190px);
  perspective: 1300px;
  cursor: grab;
}

.frame-stage:active {
  cursor: grabbing;
}

.frame-model {
  --frame-w: 420px;
  --frame-h: 535px;
  --slot-left: 8.3%;
  --slot-top: 6.6%;
  --slot-width: 83.3%;
  --slot-height: 87.1%;
  --frame-depth: 112px;
  position: relative;
  width: var(--frame-w);
  height: var(--frame-h);
  transform-style: preserve-3d;
  transform: rotateX(var(--rotate-x, -10deg)) rotateY(var(--rotate-y, -18deg));
  transition: transform 140ms ease;
}

.frame-front,
.frame-back,
.frame-side {
  position: absolute;
  transform-style: preserve-3d;
}

.frame-back {
  inset: 0;
  background: linear-gradient(135deg, #6d4328, #9a6840 52%, #4d2d19);
  border: 1px solid rgba(65, 38, 20, 0.5);
  border-radius: 7px;
  box-shadow: 26px 30px 48px rgba(31, 41, 51, 0.16);
  transform: rotateY(180deg) translateZ(calc(var(--frame-depth) / 2));
}

.frame-front {
  inset: 0;
  background: transparent;
  border: 0;
  box-shadow:
    0 30px 70px rgba(31, 41, 51, 0.24);
  overflow: visible;
  transform: translateZ(calc(var(--frame-depth) / 2));
  z-index: 2;
}

.frame-photo {
  position: absolute;
  inset: 0;
  z-index: 3;
  width: 100%;
  height: 100%;
  object-fit: fill;
  border-radius: 3px;
  pointer-events: none;
  filter: drop-shadow(0 22px 34px rgba(31, 41, 51, 0.22));
}

.frame-label {
  display: none;
}

.print-slot {
  position: absolute;
  left: var(--slot-left);
  top: var(--slot-top);
  z-index: 1;
  display: grid;
  place-items: center;
  width: var(--slot-width);
  height: var(--slot-height);
  background: rgba(255, 255, 255, 0.86);
  border: 0;
  box-shadow:
    inset 0 0 18px rgba(31, 41, 51, 0.08);
}

.frame-side {
  display: block;
  background: linear-gradient(90deg, #5f3b24 0%, #8d5f3b 52%, #744729 100%);
  border: 1px solid rgba(72, 44, 25, 0.5);
  box-shadow:
    inset 10px 0 18px rgba(45, 24, 12, 0.2),
    inset -8px 0 14px rgba(255, 224, 176, 0.12);
}

.frame-side-right {
  left: calc(50% - var(--frame-depth) / 2);
  top: 0;
  width: var(--frame-depth);
  height: var(--frame-h);
  transform: rotateY(90deg) translateZ(calc(var(--frame-w) / 2));
  border-radius: 0 7px 7px 0;
  opacity: 1;
}

.frame-side-left {
  left: calc(50% - var(--frame-depth) / 2);
  top: 0;
  width: var(--frame-depth);
  height: var(--frame-h);
  transform: rotateY(-90deg) translateZ(calc(var(--frame-w) / 2));
  border-radius: 7px 0 0 7px;
}

.frame-side-top {
  left: 0;
  top: calc(50% - var(--frame-depth) / 2);
  width: var(--frame-w);
  height: var(--frame-depth);
  transform: rotateX(90deg) translateZ(calc(var(--frame-h) / 2));
  border-radius: 7px 7px 0 0;
  background: linear-gradient(0deg, #5f3b24 0%, #8d5f3b 42%, #a7754b 70%, #6f4529 100%);
}

.frame-side-bottom {
  left: 0;
  top: calc(50% - var(--frame-depth) / 2);
  width: var(--frame-w);
  height: var(--frame-depth);
  transform: rotateX(-90deg) translateZ(calc(var(--frame-h) / 2));
  border-radius: 0 0 7px 7px;
  background: linear-gradient(0deg, #4e2e1b 0%, #7b4d2e 45%, #9a6a43 74%, #5d3821 100%);
}

#previewCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #fff;
  border-radius: 3px;
  box-shadow: none;
  cursor: move;
  touch-action: none;
}

.preview-controls {
  position: absolute;
  right: 18px;
  top: 18px;
  display: flex;
  gap: 8px;
}

.icon-button {
  min-width: 56px;
  min-height: 40px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.92);
}

.output-panel,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.output-panel {
  padding: 18px;
  box-shadow: 0 12px 30px rgba(31, 41, 51, 0.08);
}

dl {
  margin: 16px 0;
}

dl div {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid #edf1f4;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  text-align: right;
  font-weight: 700;
}

.export-grid {
  display: none;
  gap: 10px;
}

.frame-controls {
  margin-bottom: 16px;
}

.export-grid button,
.primary {
  min-height: 44px;
  border-radius: 6px;
}

.primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 700;
}

.primary:hover {
  background: var(--accent-dark);
}

.secondary-action {
  min-height: 42px;
  border-radius: 6px;
  background: #edf8ff;
  border-color: #9ed8ff;
  color: #1266a8;
  font-weight: 700;
}

.secondary-action:hover {
  background: #e0f2ff;
  border-color: #4cb6ff;
}

.editor {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100vh;
  padding: 18px;
  border-left: 1px solid var(--line);
  background: #fff;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.panel {
  padding: 16px;
}

.panel h2 {
  margin-bottom: 12px;
}

.light-hint {
  display: block;
  margin-top: 6px;
  color: #c27a12;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
}

.copy-library {
  display: grid;
  gap: 10px;
  margin: 10px 0 12px;
  padding: 12px;
  border: 1px solid #e5edf2;
  border-radius: 8px;
  background: #fbfcfd;
}

.copy-library-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.copy-library-head strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
}

.copy-library-head span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.copy-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.copy-actions button {
  min-height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

#aiCopyButton {
  background: #fff8e8;
  border-color: #e5bf69;
  color: #996913;
}

.copy-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.copy-tabs button {
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
}

.copy-tabs .active {
  border-color: var(--accent);
  background: #e7f6f6;
  color: var(--accent-dark);
  font-weight: 700;
}

.copy-list,
.ai-copy-list {
  display: grid;
  gap: 7px;
  max-height: 188px;
  overflow: auto;
  padding-right: 2px;
}

.ai-copy-list {
  padding: 8px;
  border: 1px solid #f1d79d;
  border-radius: 8px;
  background: #fffaf0;
}

.copy-list button,
.ai-copy-list button {
  min-height: 34px;
  padding: 8px 10px;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
  text-align: left;
}

.ai-copy-list button {
  border-color: #f0d08c;
}

.copy-list button:hover,
.ai-copy-list button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
}

.back-sticker-controls {
  display: grid;
  gap: 10px;
  margin: 12px 0;
  padding: 12px;
  border: 1px solid #e8eef3;
  border-radius: 8px;
  background: #fbfcfd;
}

.sticker-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.sticker-head h3 {
  margin: 0;
  font-size: 14px;
}

.sticker-head span {
  color: var(--muted);
  font-size: 12px;
}

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.sticker-grid button {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 54px;
  border-radius: 6px;
}

.sticker-grid img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.sticker-grid strong {
  font-size: 20px;
  line-height: 1;
}

.sticker-grid span {
  font-size: 12px;
  color: var(--muted);
}

.sticker-grid .active {
  border-color: var(--accent);
  background: #e7f6f6;
  color: var(--accent-dark);
}

.sticker-sliders {
  margin-top: 2px;
}

.user-sticker-upload {
  display: grid;
  place-items: center;
  min-height: 38px;
  border: 1px dashed #b8c7d3;
  border-radius: 6px;
  background: #fff;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.user-sticker-upload input {
  display: none;
}

.sticker-instance-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.sticker-instance-bar button {
  min-height: 34px;
  padding: 0 10px;
  color: #b42318;
}

.sticker-instance-bar button:disabled {
  color: var(--muted);
  opacity: 0.55;
  cursor: not-allowed;
}

.empty-gallery {
  margin: 0;
  padding: 14px;
  border: 1px dashed #cbd5df;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.segmented button,
.swatches button {
  min-height: 40px;
  border-radius: 6px;
}

.segmented .active,
.swatches .active {
  background: #e7f6f6;
  border-color: var(--accent);
  color: var(--accent-dark);
  font-weight: 700;
}

.file-drop {
  display: grid;
  place-items: center;
  min-height: 92px;
  border: 1px dashed #99abb7;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
}

.file-drop input {
  display: none;
}

.control-grid {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  color: var(--ink);
  background: #fff;
}

textarea {
  min-height: 76px;
  resize: vertical;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
}

.toggle-row input {
  width: auto;
}

.builtin-gallery {
  display: grid;
  gap: 10px;
}

.builtin-card {
  display: grid;
  grid-template-columns: 86px 1fr;
  gap: 10px;
  align-items: center;
  min-height: 74px;
  padding: 8px;
  border-radius: 8px;
  text-align: left;
}

.builtin-card.active {
  border-color: var(--accent);
  background: #e7f6f6;
  color: var(--accent-dark);
  font-weight: 700;
}

.builtin-card img {
  width: 86px;
  aspect-ratio: 1.35;
  object-fit: cover;
  border-radius: 6px;
}

.color-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: end;
  margin: 12px 0;
}

input[type="color"] {
  min-height: 42px;
  padding: 4px;
}

.color-presets {
  display: flex;
  gap: 7px;
  padding-bottom: 1px;
}

.color-presets button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
}

.color-presets .active {
  box-shadow: 0 0 0 2px var(--accent);
}

.swatches {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.swatches button {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.swatches span {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid var(--line);
}

.sketch-controls {
  display: grid;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #edf1f4;
}

.sketch-controls label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
}

.sketch-controls strong {
  color: var(--accent-dark);
  font-size: 13px;
}

[data-style="natural"] span {
  background: #80a6a8;
}

[data-style="warm"] span {
  background: var(--gold);
}

[data-style="mono"] span {
  background: #222;
}

[data-style="night"] span {
  background: #536d89;
}

.order-panel {
  display: grid;
  gap: 12px;
}

#orderResult {
  min-height: 22px;
  margin: 0;
  color: var(--accent-dark);
  font-weight: 700;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(31, 41, 51, 0.46);
}

.auth-card {
  width: min(430px, 100%);
  display: grid;
  gap: 12px;
  padding: 24px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 22px 60px rgba(31, 41, 51, 0.2);
}

.auth-card img {
  width: 220px;
  max-width: 100%;
}

.auth-card p {
  margin: 0;
  color: var(--muted);
}

#bindWechatButton {
  min-height: 42px;
  border-radius: 6px;
  background: #eef8f0;
  border-color: #9bd0a4;
  color: #247a35;
  font-weight: 700;
}

.logout-action {
  min-height: 40px;
  border-radius: 6px;
  background: #fff7f5;
  border-color: #f2b8ad;
  color: var(--danger);
  font-weight: 700;
}

#authResult {
  min-height: 22px;
  font-weight: 700;
  color: var(--accent-dark);
}

.orders-modal {
  position: fixed;
  inset: 0;
  z-index: 21;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(31, 41, 51, 0.42);
}

.orders-card {
  width: min(620px, 100%);
  max-height: min(720px, 86vh);
  overflow: auto;
  padding: 22px;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(31, 41, 51, 0.24);
}

.orders-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.orders-head button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 6px;
}

.orders-list {
  display: grid;
  gap: 10px;
}

.orders-list h3 {
  margin: 14px 0 2px;
  color: var(--ink);
  font-size: 15px;
}

.orders-list h3:first-child {
  margin-top: 0;
}

.order-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.draft-order {
  border-color: #9ed8ff;
  background: #f3fbff;
}

.purchased-work {
  border-color: #bfe3d8;
  background: #f4fbf8;
}

.work-actions {
  justify-content: flex-start !important;
  flex-wrap: wrap;
}

.inline-action {
  min-height: 30px;
  padding: 0 12px;
  border-radius: 6px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.danger-inline {
  color: var(--danger);
  border-color: #f0b7aa;
}

.inline-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.shared-flash {
  animation: sharedPulse 0.9s ease;
}

@keyframes sharedPulse {
  0% {
    box-shadow: 0 0 0 0 rgba(15, 139, 141, 0.25);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(15, 139, 141, 0.18);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(15, 139, 141, 0);
  }
}

.order-card div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.order-card span {
  color: var(--muted);
  font-size: 13px;
}

.empty-orders {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 1080px) {
  body {
    overflow: auto;
  }

  .app-shell,
  .preview-band {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .workspace {
    height: auto;
    overflow: visible;
  }

  .editor {
    height: auto;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .product-preview {
    min-height: 640px;
  }

  .frame-stage {
    min-height: 560px;
  }
}

@media (max-width: 640px) {
  .workspace,
  .editor {
    padding: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .brand-lockup {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  h1 {
    font-size: 24px;
  }

  .product-preview {
    min-height: 520px;
    padding: 12px;
  }

  .frame-stage {
    min-height: 440px;
  }

  .preview-controls {
    position: static;
    margin-top: 12px;
  }
}
