/* ============================================================
   出片工坊 · 暗房直营店
   cream paper / ink border / hard shadow / red safelight
   ============================================================ */

:root {
  --paper: #f3ecdf;
  --paper-2: #ece2cf;
  --paper-3: #e3d6bd;
  --ink: #211b12;
  --ink-soft: #5c5344;
  --red: #ff4a2e;
  --red-deep: #d9341b;
  --yellow: #ffc53d;
  --teal: #177b6f;

  --border: 2.4px solid var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  --shadow-sm: 2.5px 2.5px 0 var(--ink);
  --shadow-lg: 6px 6px 0 var(--ink);

  --font-display: "ZCOOL QingKe HuangYou", "Noto Sans SC", sans-serif;
  --font-body: "Noto Sans SC", sans-serif;
  --font-hand: "Caveat", cursive;

  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

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

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.55;
  overscroll-behavior-y: none;
}

/* 纸张颗粒 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99;
  opacity: 0.5;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3CfeColorMatrix values='0 0 0 0 0.13 0 0 0 0 0.11 0 0 0 0 0.07 0 0 0 0.05 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

.app {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--paper);
  box-shadow: 0 0 0 1px rgba(33, 27, 18, 0.08), 0 18px 60px rgba(33, 27, 18, 0.12);
}

/* ---------------- 品牌条 ---------------- */
.brandbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px 10px;
  background: var(--paper);
  border-bottom: var(--border);
}
.brandbar__back {
  width: 40px; height: 40px;
  flex: none;
  display: grid; place-items: center;
  border: var(--border);
  border-radius: 12px;
  background: var(--paper-2);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.brandbar__back:active { transform: translate(2px, 2px); box-shadow: none; }
.brandbar__back svg { width: 20px; height: 20px; }
.brandbar__title { line-height: 1.15; flex: 1; min-width: 0; }
.brandbar__name {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.04em;
}
.brandbar__sub {
  display: block;
  font-size: 11px;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brandbar__stamp {
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.12em;
  color: var(--red);
  border: 2px solid var(--red);
  border-radius: 6px;
  padding: 2px 7px 1px;
  transform: rotate(8deg);
  transform-origin: center;
}

/* ---------------- 视图切换 ---------------- */
.stage { position: relative; }
.view {
  display: none;
  padding: 18px 16px 28px;
  animation: view-in 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.app[data-view="wall"]    .view--wall,
.app[data-view="work"]    .view--work,
.app[data-view="loading"] .view--loading,
.app[data-view="result"]  .view--result { display: block; }

@keyframes view-in {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ---------------- HERO ---------------- */
.hero { position: relative; margin-bottom: 26px; }
.hero__kicker {
  font-family: var(--font-hand);
  font-size: 17px;
  font-weight: 700;
  color: var(--red);
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.hero__title {
  font-family: var(--font-display);
  font-size: clamp(38px, 9.5vw, 50px);
  line-height: 1.06;
  letter-spacing: 0.03em;
}
.hero__title em {
  font-style: normal;
  color: var(--paper);
  background: var(--red);
  padding: 0 10px;
  border: var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  display: inline-block;
  transform: rotate(-1.5deg);
}
.hero__desc {
  margin-top: 12px;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.hero__ticker {
  margin-top: 16px;
  border-block: var(--border);
  overflow: hidden;
  background: var(--yellow);
  transform: rotate(-1deg);
}
.hero__ticker-track {
  display: flex;
  gap: 14px;
  white-space: nowrap;
  padding: 6px 0;
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: 0.06em;
  animation: ticker 22s linear infinite;
  width: max-content;
}
.hero__ticker-track i { color: var(--red); font-style: normal; }
@keyframes ticker {
  to { transform: translateX(-50%); }
}

.wall-section-title {
  font-family: var(--font-display);
  font-size: 21px;
  letter-spacing: 0.04em;
  margin: 4px 2px 14px;
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.wall-section-title__no {
  font-family: var(--font-hand);
  font-size: 30px;
  color: var(--red);
}

/* ---------------- 玩法墙卡片 ---------------- */
.wall {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.card {
  border: var(--border);
  border-radius: 14px;
  background: #fbf6ec;
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  animation: card-in 0.5s both;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.card:active { transform: translate(4px, 4px); box-shadow: none; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(16px) rotate(1deg); }
  to   { opacity: 1; transform: none; }
}

.card__cover {
  position: relative;
  aspect-ratio: 4 / 3.15;
  overflow: hidden;
  border-bottom: var(--border);
  display: grid;
  place-items: center;
}
.card__cover::after {
  /* 网点纹理 */
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(currentColor 1.1px, transparent 1.3px);
  background-size: 9px 9px;
  opacity: 0.18;
}
.card__no {
  position: absolute;
  top: 7px; left: 9px;
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 19px;
  z-index: 2;
}
.card__badge {
  position: absolute;
  top: 7px; right: 7px;
  z-index: 2;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 2px 7px;
  border: 1.8px solid currentColor;
  border-radius: 99px;
  background: rgba(243, 236, 223, 0.85);
}
.card__glyph {
  font-family: var(--font-display);
  font-size: 64px;
  line-height: 1;
  transform: rotate(-6deg);
  z-index: 1;
}
.card__body { padding: 9px 11px 11px; }
.card__name {
  font-family: var(--font-display);
  font-size: 18.5px;
  letter-spacing: 0.03em;
}
.card__tag {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--ink-soft);
  line-height: 1.4;
}
.card__input {
  margin-top: 7px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  border: 1.8px solid var(--ink);
  border-radius: 6px;
  padding: 1px 6px;
  background: var(--paper-2);
}

.wall-foot {
  margin-top: 20px;
  text-align: center;
  font-size: 11px;
  color: var(--ink-soft);
}

/* ---------------- 工作台 ---------------- */
.work-cover {
  display: flex;
  align-items: center;
  gap: 12px;
  border: var(--border);
  border-radius: 14px;
  padding: 12px;
  background: #fbf6ec;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.work-cover__tile {
  width: 64px; height: 64px;
  flex: none;
  border: var(--border);
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 34px;
  position: relative;
  overflow: hidden;
}
.work-cover__tile::after {
  content: "";
  position: absolute; inset: 0;
  background-image: radial-gradient(currentColor 1px, transparent 1.2px);
  background-size: 7px 7px;
  opacity: 0.18;
}
.work-cover__name {
  font-family: var(--font-display);
  font-size: 23px;
  letter-spacing: 0.03em;
  line-height: 1.2;
}
.work-cover__tag { font-size: 12px; color: var(--ink-soft); }

.block-label {
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: 0.04em;
  margin: 18px 2px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.block-label::before {
  content: "";
  width: 9px; height: 9px;
  background: var(--red);
  border: 1.6px solid var(--ink);
  border-radius: 3px;
  transform: rotate(4deg);
}
.block-label .req { color: var(--red); font-family: var(--font-body); font-size: 13px; }

/* 上传槽 */
.slot {
  position: relative;
  border: 2.4px dashed var(--ink);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.35);
  min-height: 132px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 14px;
  cursor: pointer;
  margin-bottom: 12px;
  text-align: center;
  transition: background 0.15s, transform 0.1s;
}
.slot:active { transform: scale(0.99); }
.slot--filled {
  padding: 0;
  border-style: solid;
  overflow: hidden;
  cursor: default;
  background: none;
  min-height: 0;
}
.slot__plus {
  width: 42px; height: 42px;
  border: var(--border);
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: var(--shadow-sm);
  display: grid; place-items: center;
  font-size: 24px;
  font-weight: 900;
}
.slot__label { font-weight: 700; font-size: 14px; }
.slot__hint { font-size: 11.5px; color: var(--ink-soft); }
.slot__thumb { width: 100%; display: block; max-height: 300px; object-fit: cover; }
.slot__ops {
  position: absolute;
  top: 8px; right: 8px;
  display: flex; gap: 8px;
}
.slot__op {
  border: var(--border);
  border-radius: 99px;
  background: var(--paper);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
}
.slot__op:active { transform: translate(2px, 2px); box-shadow: none; }
.slot__op--danger { background: var(--red); color: var(--paper); }
.slot__idx {
  position: absolute;
  top: 8px; left: 8px;
  font-family: var(--font-hand);
  font-weight: 700;
  font-size: 20px;
  background: var(--paper);
  border: 1.8px solid var(--ink);
  border-radius: 8px;
  padding: 0 7px;
  z-index: 2;
}
.slot-add {
  width: 100%;
  border: 2.4px dashed var(--ink);
  border-radius: 14px;
  background: transparent;
  font: inherit;
  font-weight: 700;
  font-size: 13.5px;
  padding: 13px;
  cursor: pointer;
  color: var(--ink-soft);
  margin-bottom: 12px;
}
.slot-add:active { background: var(--paper-2); }

/* 参数表单 */
.var { margin-bottom: 14px; }
.var__label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  margin: 0 2px 6px;
}
.var__label .req { color: var(--red); }
.var input[type="text"],
.var select {
  width: 100%;
  font: inherit;
  font-size: 14.5px;
  color: var(--ink);
  background: #fbf6ec;
  border: var(--border);
  border-radius: 12px;
  padding: 12px 13px;
  box-shadow: var(--shadow-sm);
  appearance: none;
  -webkit-appearance: none;
}
.var input[type="text"]:focus,
.var select:focus {
  outline: none;
  background-color: #fff;
  box-shadow: var(--shadow-sm), 0 0 0 3px rgba(255, 74, 46, 0.25);
}
.var select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 10'%3E%3Cpath d='M1 1l7 7 7-7' fill='none' stroke='%23211b12' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 15px 9px;
  padding-right: 40px;
}
.var textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background: #fbf6ec;
  border: var(--border);
  border-radius: 12px;
  padding: 12px 13px;
  box-shadow: var(--shadow-sm);
  resize: vertical;
  min-height: 84px;
}
.var textarea:focus {
  outline: none;
  background: #fff;
  box-shadow: var(--shadow-sm), 0 0 0 3px rgba(255, 74, 46, 0.25);
}
.var-custom {
  margin-top: 10px;
  padding: 12px;
  border: var(--border);
  border-radius: 12px;
  background: var(--paper-2);
}
.var-custom .var { margin-bottom: 10px; }
.var-custom .var:last-child { margin-bottom: 0; }
.var__ph { font-size: 11px; color: var(--ink-soft); margin: 5px 2px 0; }

.work-spacer { height: 110px; }

/* CTA 吸底 */
.cta-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 480px;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: linear-gradient(to top, var(--paper) 72%, rgba(243, 236, 223, 0));
  z-index: 30;
}
.btn-primary {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.08em;
  color: var(--paper);
  background: var(--red);
  border: var(--border);
  border-radius: 14px;
  padding: 14px 18px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s;
}
.btn-primary:active:not(:disabled) {
  transform: translate(4px, 4px);
  box-shadow: none;
}
.btn-primary:disabled {
  background: var(--paper-3);
  color: rgba(33, 27, 18, 0.55);
  box-shadow: none;
  cursor: not-allowed;
}
.btn-primary__arrow { font-size: 24px; }
.cta-bar__hint {
  text-align: center;
  font-size: 11px;
  color: var(--ink-soft);
  margin-top: 7px;
}

/* ---------------- 冲印中 ---------------- */
.view--loading { padding-top: 9vh; }
.darkroom {
  border: var(--border);
  border-radius: 18px;
  background: #171009;
  color: #f3ecdf;
  padding: 34px 24px 28px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  position: relative;
  overflow: hidden;
}
.darkroom::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% -10%, rgba(255, 74, 46, 0.28), transparent 55%);
  pointer-events: none;
}
.darkroom__bulb {
  width: 58px; height: 58px;
  margin: 0 auto 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffb09e, var(--red) 55%, #8f1f0e);
  border: var(--border);
  border-color: #f3ecdf;
  display: grid;
  place-items: center;
  animation: bulb 1.6s ease-in-out infinite;
  box-shadow: 0 0 34px rgba(255, 74, 46, 0.7);
}
.darkroom__bulb span {
  width: 18px; height: 24px;
  border-radius: 50% 50% 46% 46%;
  background: rgba(243, 236, 223, 0.85);
}
@keyframes bulb {
  0%, 100% { filter: brightness(0.75); }
  50% { filter: brightness(1.25); }
}
.darkroom__title {
  font-family: var(--font-display);
  font-size: 34px;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
}
.darkroom__tip {
  margin-top: 10px;
  font-size: 13px;
  color: rgba(243, 236, 223, 0.75);
  min-height: 20px;
  transition: opacity 0.3s;
}
.darkroom__timer {
  margin-top: 6px;
  font-family: var(--font-hand);
  font-size: 26px;
  color: var(--yellow);
}
.darkroom__film {
  margin-top: 22px;
  display: flex;
  justify-content: center;
  gap: 9px;
}
.darkroom__film i {
  width: 14px; height: 22px;
  border: 2px solid rgba(243, 236, 223, 0.55);
  border-radius: 3px;
  animation: film 1.2s ease-in-out infinite;
}
.darkroom__film i:nth-child(2) { animation-delay: 0.15s; }
.darkroom__film i:nth-child(3) { animation-delay: 0.3s; }
.darkroom__film i:nth-child(4) { animation-delay: 0.45s; }
.darkroom__film i:nth-child(5) { animation-delay: 0.6s; }
@keyframes film {
  0%, 100% { transform: translateY(0); opacity: 0.5; }
  50% { transform: translateY(-8px); opacity: 1; }
}
.darkroom__cancel {
  margin-top: 22px;
  background: none;
  border: 1.8px solid rgba(243, 236, 223, 0.6);
  color: rgba(243, 236, 223, 0.85);
  border-radius: 99px;
  font: inherit;
  font-size: 13px;
  padding: 8px 22px;
  cursor: pointer;
}

/* ---------------- 结果页 ---------------- */
.result-polaroid {
  background: #fbf6ec;
  border: var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow-lg);
  padding: 12px 12px 0;
  transform: rotate(-1.2deg);
}
.result-polaroid__img {
  width: 100%;
  display: block;
  border: 1.8px solid var(--ink);
  border-radius: 3px;
  background: var(--paper-2);
}
.result-polaroid__cap {
  font-family: var(--font-hand);
  font-size: 24px;
  text-align: center;
  padding: 8px 0 12px;
  color: var(--ink);
}
.result-meta {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 20px 0 4px;
}
.tag-chip {
  font-size: 11px;
  font-weight: 700;
  border: 1.8px solid var(--ink);
  border-radius: 99px;
  padding: 3px 11px;
  background: var(--paper-2);
}
.tag-chip--gemini { background: var(--teal); color: var(--paper); }
.result-actions { margin-top: 18px; display: grid; gap: 10px; }
.btn-ghost {
  width: 100%;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  border: var(--border);
  border-radius: 12px;
  background: #fbf6ec;
  box-shadow: var(--shadow-sm);
  padding: 13px;
  cursor: pointer;
}
.btn-ghost:active { transform: translate(2px, 2px); box-shadow: none; }
.result-actions .btn-primary { font-size: 19px; padding: 13px; }

/* 错误面板（撕纸感） */
.error-panel {
  border: var(--border);
  border-radius: 14px;
  background: #fbf6ec;
  box-shadow: var(--shadow);
  padding: 26px 22px;
  text-align: center;
  position: relative;
}
.error-panel__icon {
  width: 60px; height: 60px;
  margin: 0 auto 14px;
  border: var(--border);
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 32px;
  background: var(--yellow);
  box-shadow: var(--shadow-sm);
}
.error-panel--quota .error-panel__icon { background: var(--red); color: var(--paper); }
.error-panel__title {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 0.04em;
}
.error-panel__msg {
  margin-top: 8px;
  font-size: 13.5px;
  color: var(--ink-soft);
}
.error-panel__actions { margin-top: 18px; display: grid; gap: 10px; }

.skeleton-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.skeleton {
  height: 188px;
  border: var(--border);
  border-radius: 14px;
  background: linear-gradient(100deg, var(--paper-2) 40%, #f8f2e6 50%, var(--paper-2) 60%);
  background-size: 220% 100%;
  animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { to { background-position: -120% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
