:root {
  --bg: #e6eef3;
  --bg-deep: #d5e3eb;
  --ink: #102033;
  --muted: #5a6d7e;
  --card: #ffffff;
  --line: #c9d7e2;
  --accent: #0d7c74;
  --accent-2: #0a5f8a;
  --accent-soft: #d7f0ed;
  --accent-ink: #ffffff;
  --warn: #9a4d12;
  --warn-bg: #fff1e0;
  --ok: #1a7a52;
  --ok-bg: #e5f6ee;
  --err: #b42318;
  --err-bg: #fdeceb;
  --shell: 430px;
  --radius: 14px;
  --font-brand: "Syne", "Noto Sans SC", sans-serif;
  --font-body: "Noto Sans SC", "PingFang SC", sans-serif;
}

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

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(13, 124, 116, 0.18), transparent 55%),
    radial-gradient(ellipse 70% 45% at 100% 0%, rgba(10, 95, 138, 0.16), transparent 50%),
    linear-gradient(165deg, var(--bg) 0%, #f3f7fa 48%, var(--bg-deep) 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.35;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='120' height='120' filter='url(%23n)' opacity='0.45'/%3E%3C/svg%3E");
}

.page {
  width: min(100%, var(--shell));
  margin: 0 auto;
  padding: 20px 16px calc(28px + env(safe-area-inset-bottom));
}

.header h1 {
  margin: 4px 0 8px;
  font-family: var(--font-brand);
  font-size: clamp(1.6rem, 5vw, 1.9rem);
  letter-spacing: -0.02em;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.sub {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.card {
  margin-top: 16px;
  padding: 18px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.file-picker {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 168px;
  padding: 24px 16px;
  border: 1.5px dashed var(--line);
  border-radius: var(--radius);
  background: #f4f8fb;
  text-align: center;
  cursor: pointer;
}

.file-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

.picker-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 24px;
  line-height: 1;
}

.picker-title {
  font-size: 17px;
  font-weight: 650;
}

.picker-hint {
  margin-top: 8px;
  max-width: 240px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.preview-wrap {
  margin-top: 16px;
}

.preview-wrap.hidden {
  display: none;
}

.preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.preview-head h2 {
  margin: 0;
  font-size: 15px;
}

.preview-count {
  min-width: 24px;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.preview-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
  max-height: 360px;
  overflow: auto;
}

.preview-item {
  display: grid;
  grid-template-columns: 64px 1fr 36px;
  gap: 10px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.thumb {
  width: 64px;
  height: 64px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  display: grid;
  place-items: center;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.meta .name {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  word-break: break-all;
}

.meta .dest {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.remove {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 10px;
  background: #eef3f7;
  color: var(--ink);
  font-size: 20px;
  cursor: pointer;
}

.admin-link {
  margin: 28px 0 0;
  text-align: center;
}

.admin-link a {
  color: var(--muted);
  font-size: 13px;
  text-decoration: none;
}

.admin-link a:active {
  color: var(--accent);
}

.actions {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.btn {
  min-height: 48px;
  border: 0;
  border-radius: 12px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, opacity 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

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

.btn.primary {
  background: linear-gradient(135deg, var(--accent) 0%, #0a6a8f 100%);
  color: var(--accent-ink);
}

.btn.ghost {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}

.status {
  min-height: 22px;
  margin: 14px 0 0;
  font-size: 14px;
  line-height: 1.5;
}

.status.ok {
  color: var(--ok);
}

.status.err {
  color: var(--err);
}

.home-done {
  margin: 0 0 14px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--ok-bg);
  color: var(--ok);
  text-align: center;
  font-weight: 650;
  animation: rise 0.35s ease;
}

.home-done a {
  color: var(--accent-2);
  font-weight: 700;
}

.home-body {
  min-height: 100%;
}

/* —— 顶栏 —— */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  width: min(100%, var(--shell));
  min-height: 52px;
  margin: 0 auto;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(201, 215, 226, 0.7);
  color: var(--ink);
}

.topbar .brand {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.topbar .top-sub,
.topbar .back {
  margin: 0;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.topbar .back {
  flex-shrink: 0;
  padding: 6px 0;
  font-weight: 600;
}

.topbar .back:active {
  color: var(--accent);
}

.page.home {
  padding-top: 8px;
  animation: rise 0.4s ease;
}

/* —— 首页品牌区 —— */
.hero-card {
  position: relative;
  overflow: hidden;
  padding: 28px 20px 26px;
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0.12)),
    linear-gradient(160deg, #0a5f8a 0%, #0d7c74 55%, #0b5c56 100%);
  color: #fff;
  box-shadow: 0 12px 28px rgba(10, 95, 138, 0.18);
}

.hero-card::after {
  content: "";
  position: absolute;
  right: -20%;
  top: -30%;
  width: 70%;
  height: 90%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.16), transparent 70%);
  pointer-events: none;
}

.hero-kicker {
  margin: 0;
  position: relative;
  z-index: 1;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0.85;
}

.hero-brand {
  position: relative;
  z-index: 1;
  margin: 10px 0 8px;
  font-family: var(--font-brand);
  font-size: clamp(2.1rem, 9vw, 2.55rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.hero-card h1 {
  position: relative;
  z-index: 1;
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 600;
  opacity: 0.95;
}

.hero-card > p:last-child {
  position: relative;
  z-index: 1;
  margin: 0;
  max-width: 28em;
  font-size: 13px;
  line-height: 1.55;
  opacity: 0.88;
}

.group-title {
  margin: 26px 0 12px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  text-transform: uppercase;
}

.tile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 104px;
  padding: 16px 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: transform 0.18s ease, border-color 0.18s ease, background 0.18s ease;
  animation: rise 0.45s ease both;
}

.tile:nth-child(1) { animation-delay: 0.04s; }
.tile:nth-child(2) { animation-delay: 0.08s; }
.tile:nth-child(3) { animation-delay: 0.12s; }
.tile:nth-child(4) { animation-delay: 0.16s; }
.tile:nth-child(5) { animation-delay: 0.2s; }
.tile:nth-child(6) { animation-delay: 0.24s; }

.tile:active {
  transform: scale(0.98);
  border-color: var(--accent);
  background: #fff;
}

.tile-title {
  font-weight: 700;
  font-size: 15px;
}

.tile-desc {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.list-cards {
  display: grid;
  gap: 10px;
  width: min(100%, var(--shell));
  margin: 0 auto;
}

.row-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.row-card:active {
  transform: scale(0.99);
  border-color: var(--accent);
}

.row-card strong {
  font-size: 16px;
}

.row-card small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.row-card .size-count:not(:empty) {
  margin-top: 6px;
  color: var(--accent);
  font-weight: 650;
}

.chev {
  color: #9aafbf;
  font-size: 22px;
  font-weight: 300;
}

.pick-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.pick-btn {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 48px;
  border-radius: 12px;
  background: #eef3f7;
  font-weight: 650;
  cursor: pointer;
}

.pick-btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

.pick-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.toggle {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 14px;
  font-size: 14px;
}

.notice {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--accent-soft);
  color: #0a5a55;
  font-size: 13px;
}

/* —— 照片页 —— */
.photo-body {
  background: transparent;
}

.photo-page {
  width: min(100%, var(--shell));
  margin: 0 auto;
  padding: 12px 14px calc(150px + env(safe-area-inset-bottom));
}

.count-bar {
  margin: 0 0 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  color: var(--ink);
  text-align: center;
  font-size: 14px;
  font-weight: 700;
}

.crop-banner {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: #0a5a55;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.45;
}

.more-sizes {
  margin-top: 4px;
}

.more-sizes[open] {
  margin-top: 8px;
  padding: 8px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #f4f8fb;
}

.more-sizes summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  list-style: none;
}

.more-sizes summary::-webkit-details-marker {
  display: none;
}

.more-size-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  font-size: 13px;
}

.more-size-row .qty {
  margin-top: 0;
}

.empty-state {
  min-height: 42vh;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 15px;
}

.empty-state.hidden,
.hidden {
  display: none !important;
}

.photo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  align-items: start;
}

.photo-cell {
  position: relative;
  animation: rise 0.3s ease both;
}

.photo-thumb {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #1a2430;
  cursor: pointer;
}

.photo-thumb canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
}

.crop-warn,
.edit-hint {
  position: absolute;
  left: 0;
  right: 0;
  color: #fff;
  font-size: 12px;
  text-align: center;
}

.crop-warn {
  top: 0;
  padding: 4px;
  background: rgba(180, 35, 24, 0.8);
}

.edit-hint {
  bottom: 0;
  padding: 8px 4px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.55));
}

.photo-x {
  position: absolute;
  top: -8px;
  right: -8px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  font-size: 18px;
}

.qty {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.qty button {
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 16px;
}

.photo-bottom {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 15;
  width: min(100%, var(--shell));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}

.photo-actions {
  display: flex;
  gap: 10px;
}

.grow {
  flex: 1;
  position: relative;
  display: grid;
  place-items: center;
}

.grow input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.photo-status {
  margin: 0;
  min-height: 0;
  text-align: center;
  font-weight: 650;
}

.photo-status:empty {
  display: none;
}

.photo-status.ok,
.photo-status.err {
  padding: 8px 10px;
  border-radius: 8px;
}

.photo-status.ok {
  background: var(--ok-bg);
}

.photo-status.err {
  background: var(--err-bg);
}

.editor {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  width: min(100%, var(--shell));
  margin: 0 auto;
  background: #0f1822;
  color: #fff;
}

.editor-top {
  display: grid;
  grid-template-columns: 64px 1fr 64px;
  align-items: center;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
}

.editor-top p {
  margin: 0;
  text-align: center;
  font-weight: 700;
}

.editor-back,
.editor-done {
  border: 0;
  background: transparent;
  color: #9fe0d8;
  font-size: 15px;
  font-weight: 650;
  min-height: 40px;
}

.editor-hint {
  margin: 0 12px 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(13, 124, 116, 0.22);
  color: #9fe0d8;
  font-size: 12px;
  text-align: center;
  line-height: 1.45;
}

.stage {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  touch-action: none;
  padding: 4px 14px 10px;
}

.print-frame {
  position: relative;
  max-width: 100%;
  overflow: hidden;
  background: #fff;
  border-radius: 4px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.editor-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 0 12px 6px;
}

.print-frame canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.margin-tag {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 2;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(16, 32, 51, 0.55);
  color: #fff;
  font-size: 11px;
  font-weight: 650;
}

.frame-marks:before,
.frame-marks:after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.9);
  z-index: 2;
  pointer-events: none;
}

.frame-marks:before {
  top: 6px;
  left: 6px;
  border-right: 0;
  border-bottom: 0;
}

.frame-marks:after {
  right: 6px;
  bottom: 6px;
  border-left: 0;
  border-top: 0;
}

.editor-bar {
  display: grid;
  gap: 8px;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom));
}

.chip {
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid #4a5c6c;
  border-radius: 10px;
  background: transparent;
  color: #fff;
  font-family: inherit;
  font-size: 13px;
}

.chip.on {
  border-color: #4fd1c5;
  color: #4fd1c5;
  background: rgba(79, 209, 197, 0.1);
}

.cart-fab {
  position: fixed;
  right: max(12px, calc(50% - var(--shell) / 2 + 12px));
  bottom: calc(88px + env(safe-area-inset-bottom));
  z-index: 18;
  min-height: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: var(--ink);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(16, 32, 51, 0.28);
}

.cart-fab span {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  margin-left: 6px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--accent);
  font-variant-numeric: tabular-nums;
}

.cart-sheet {
  position: fixed;
  inset: 0;
  z-index: 25;
  display: grid;
  align-items: end;
  justify-items: center;
  padding: 12px;
  background: rgba(16, 32, 51, 0.45);
}

.cart-sheet-card {
  width: min(100%, var(--shell));
  max-height: min(70vh, 520px);
  display: flex;
  flex-direction: column;
  padding: 14px;
  border-radius: 16px 16px 12px 12px;
  background: #fff;
  animation: pop 0.22s ease;
}

.cart-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.cart-close {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-weight: 650;
}

.cart-list {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow: auto;
}

.cart-item,
.cart-empty {
  padding: 12px 4px;
  border-top: 1px solid var(--line);
}

.cart-item {
  display: grid;
  gap: 4px;
}

.cart-item strong {
  font-size: 14px;
  word-break: break-all;
}

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

.cart-empty {
  color: var(--muted);
  text-align: center;
}

.busy {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  background: rgba(16, 32, 51, 0.5);
}

.done-mask {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(16, 32, 51, 0.52);
}

.done-card {
  width: min(340px, 100%);
  display: grid;
  gap: 10px;
  padding: 22px 18px 16px;
  border-radius: 16px;
  background: #fff;
  text-align: center;
  animation: pop 0.25s ease;
}

.done-title {
  margin: 0;
  font-family: var(--font-brand);
  font-size: 1.35rem;
  font-weight: 750;
}

.done-text {
  margin: 0 0 6px;
  color: var(--muted);
  line-height: 1.5;
}

.busy-card {
  display: grid;
  gap: 10px;
  place-items: center;
  padding: 24px;
  border-radius: 16px;
  background: rgba(15, 24, 34, 0.92);
  color: #fff;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(255, 255, 255, 0.22);
  border-top-color: #4fd1c5;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (min-width: 520px) {
  .page,
  .photo-page,
  .list-cards {
    padding-left: 20px;
    padding-right: 20px;
  }

  .tile-grid {
    gap: 12px;
  }
}

@media (max-width: 360px) {
  .tile-grid {
    grid-template-columns: 1fr;
  }

  .photo-actions {
    flex-direction: column;
  }

  .photo-page {
    padding-bottom: calc(190px + env(safe-area-inset-bottom));
  }
}
