:root {
  --bg: #2c2622;
  --bg-deep: #1a1613;
  --bg-warm: #3a322c;
  --cream: #f6efe6;
  --cream-2: #efe6db;
  --cream-hi: #fbf6f0;
  --ink: #2a221c;
  --ink-soft: #5a5048;
  --gold: #d4b483;
  --gold-bright: #f3e4c4;
  --gold-mid: #c9a56a;
  --gold-dark: #9a7540;
  --card-radius: 22px;
  --slot-radius: 14px;
  --canvas-w: 696px;
  --toolbar-h: 56px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0;
  padding: 0;
  background: #0e0c0a;
  color: #fff;
  font-family: var(--font);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { padding-bottom: calc(20px + var(--safe-bottom)); }

/* ===== Toolbar ===== */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(14, 12, 10, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(212, 180, 131, 0.22);
  padding-top: var(--safe-top);
}
.toolbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: var(--toolbar-h);
  padding: 8px 12px;
  max-width: 760px;
  margin: 0 auto;
}
.toolbar-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--gold-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toolbar-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 12px;
  font-weight: 700;
}
.toolbar-actions { display: flex; gap: 8px; flex-shrink: 0; }
.toolbar-hint {
  margin: 0 auto;
  padding: 0 12px 10px;
  max-width: 760px;
  font-size: 12px;
  color: rgba(240, 223, 192, 0.7);
}
.toolbar-hint[hidden] { display: none; }

.btn {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  min-height: 40px;
}
.btn-primary {
  background: linear-gradient(180deg, #edd9b0, #c9a56a);
  color: #2a1e10;
  box-shadow: 0 2px 12px rgba(201, 165, 106, 0.4);
}
.btn-primary:active { transform: scale(0.97); }
.btn-ghost {
  background: transparent;
  color: var(--gold-bright);
  border: 1px solid rgba(212, 180, 131, 0.45);
}
.btn:disabled { opacity: 0.55; cursor: wait; }

/* ===== Stage / Canvas ===== */
.stage {
  padding: 14px 8px 36px;
  display: flex;
  justify-content: center;
}
.canvas {
  width: min(100%, var(--canvas-w));
  background:
    url("assets/canvas-glow.jpg") top center / 100% 280px no-repeat,
    radial-gradient(90% 28% at 50% 0%, rgba(210, 170, 110, 0.28), transparent 60%),
    radial-gradient(70% 20% at 50% 100%, rgba(160, 120, 70, 0.12), transparent 55%),
    linear-gradient(180deg, #3f362f 0%, var(--bg) 14%, #221c18 72%, var(--bg-deep) 100%);
  border-radius: 6px;
  overflow: hidden;
  box-shadow:
    0 18px 48px rgba(0,0,0,0.55),
    0 0 0 1px rgba(212, 180, 131, 0.12);
  padding: 16px 14px 18px;
}

/* Editable focus */
[contenteditable="true"] {
  outline: none;
  border-radius: 4px;
  cursor: text;
  transition: box-shadow 0.15s, background 0.15s;
}
[contenteditable="true"]:focus {
  box-shadow: 0 0 0 2px rgba(201, 165, 106, 0.7);
  background: rgba(201, 165, 106, 0.14);
}
.exporting-mode [contenteditable="true"]:focus {
  box-shadow: none !important;
  background: transparent !important;
}

/* ===== Header module ===== */
.mod-header {
  text-align: center;
  padding: 4px 6px 14px;
  position: relative;
}
.badge-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 10px;
}
.badge-line {
  width: 42px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(245, 230, 200, 0.85), transparent);
  opacity: 0.85;
}
.badge-03 {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  padding: 3px 16px 4px;
  border-radius: 6px;
  background: linear-gradient(180deg, #f7efe3 0%, #e8d5b4 100%);
  color: #3a2e22;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.06em;
  font-style: italic;
  box-shadow:
    0 2px 8px rgba(0,0,0,0.25),
    inset 0 1px 0 rgba(255,255,255,0.55);
}
.title-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.laurel { width: 34px; height: 46px; flex-shrink: 0; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35)); }
.main-title {
  margin: 0;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 0.18em;
  background: linear-gradient(180deg, #fffaf0 0%, #f0dfc0 38%, #d4b07a 78%, #b8924a 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  line-height: 1.15;
  text-shadow: none;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.35));
}
.subtitle {
  margin: 10px 4px 0;
  font-size: 12.5px;
  font-weight: 400;
  color: rgba(255, 248, 236, 0.9);
  letter-spacing: 0.06em;
  line-height: 1.55;
}
.subtitle::before,
.subtitle::after {
  content: "";
  display: inline-block;
  width: 36px;
  height: 1px;
  margin: 0 10px;
  vertical-align: middle;
  background: linear-gradient(90deg, transparent, rgba(240,223,192,0.75));
}
.subtitle::after {
  background: linear-gradient(90deg, rgba(240,223,192,0.75), transparent);
}

/* ===== Cards ===== */
.card {
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(255,255,255,0.55), transparent 45%),
    linear-gradient(165deg, var(--cream-hi) 0%, var(--cream) 48%, var(--cream-2) 100%);
  border-radius: var(--card-radius);
  margin: 0 0 9px;
  overflow: hidden;
  border: 1px solid rgba(255, 248, 236, 0.35);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.35) inset,
    0 0 0 1px rgba(180, 140, 90, 0.08),
    0 4px 10px rgba(0,0,0,0.18),
    0 12px 28px rgba(0,0,0,0.28),
    0 0 24px rgba(201, 165, 106, 0.08);
}
.card:last-of-type { margin-bottom: 10px; }

.card-body {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.18fr);
  gap: 0;
  min-height: 158px;
  align-items: stretch;
}
.card-body-stack {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
}

.card-text {
  position: relative;
  padding: 18px 12px 16px 18px;
  color: var(--ink);
  display: flex;
  flex-direction: column;
  justify-content: center;
  z-index: 1;
}
/* Soft organic curve into media */
.card-body:not(.card-body-stack) .card-text::after {
  content: "";
  position: absolute;
  top: -8%;
  right: -22px;
  width: 44px;
  height: 116%;
  background: inherit;
  background: linear-gradient(165deg, var(--cream-hi) 0%, var(--cream) 48%, var(--cream-2) 100%);
  border-radius: 50%;
  z-index: 0;
  pointer-events: none;
  box-shadow: 8px 0 18px rgba(0,0,0,0.04);
}
.card-text-full {
  padding: 16px 16px 6px 18px;
}
.card-text-full::after { display: none; }

.card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
  z-index: 1;
}
.icon {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: linear-gradient(160deg, #3a322c, #1e1915);
  color: #f3e4c4;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow:
    0 2px 6px rgba(0,0,0,0.28),
    inset 0 1px 0 rgba(255,255,255,0.12);
}
.icon svg { width: 14px; height: 14px; }
.card-title {
  margin: 0;
  font-size: 16.5px;
  font-weight: 800;
  color: var(--ink);
  line-height: 1.25;
  letter-spacing: 0.02em;
  background: linear-gradient(90deg, rgba(212,180,131,0.42), rgba(212,180,131,0.08) 72%, transparent);
  padding: 3px 10px 3px 6px;
  border-radius: 4px;
  position: relative;
  z-index: 1;
}
.divider {
  width: 26px;
  height: 2.5px;
  background: var(--ink);
  margin: 9px 0 8px;
  opacity: 0.82;
  border-radius: 2px;
  position: relative;
  z-index: 1;
}
.card-desc {
  margin: 0;
  font-size: 12px;
  line-height: 1.72;
  color: var(--ink-soft);
  font-weight: 400;
  position: relative;
  z-index: 1;
}

.card-media {
  position: relative;
  min-height: 150px;
  padding: 10px 10px 10px 4px;
  display: flex;
  z-index: 1;
}
.card-media .img-slot {
  flex: 1;
  min-height: 140px;
}

/* Image slots */
.img-slot {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--slot-radius);
  background: #d6cdc0;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: inset 0 0 0 1px rgba(42, 34, 28, 0.06);
}
.img-slot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  pointer-events: none;
  min-height: 140px;
}
.img-slot input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  font-size: 0;
}
.img-tip {
  position: absolute;
  right: 6px;
  top: 6px;
  z-index: 2;
  pointer-events: none;
  background: rgba(42, 36, 32, 0.55);
  color: rgba(245, 230, 200, 0.95);
  font-size: 10px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.18s, transform 0.18s;
  letter-spacing: 0.02em;
  border: 1px solid rgba(255,255,255,0.12);
}
.img-slot:hover .img-tip,
.img-slot:focus-within .img-tip,
.img-slot:active .img-tip {
  opacity: 1;
  transform: translateY(0);
}
@media (hover: none) {
  .img-tip {
    opacity: 0;
    top: 6px;
    right: 6px;
    font-size: 9px;
    padding: 2px 7px;
  }
  .img-slot:active .img-tip,
  .img-slot:focus-within .img-tip {
    opacity: 0.85;
  }
}
.exporting-mode .img-tip { opacity: 0 !important; }

/* Card 2 mid chevron + inset */
.has-inset { position: relative; }
.mid-chevron {
  position: absolute;
  left: -2px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 4;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(145deg, #f0dfc0, #c9a56a 55%, #a8874e);
  color: #2a1e10;
  font-weight: 900;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 3px 10px rgba(0,0,0,0.28),
    0 0 12px rgba(201, 165, 106, 0.45);
  letter-spacing: -3px;
  padding-left: 2px;
  pointer-events: none;
}
.inset-circle {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 104px;
  height: 104px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid #f8f1e6;
  box-shadow:
    0 8px 22px rgba(0,0,0,0.4),
    0 0 0 1px rgba(180, 140, 90, 0.35),
    0 0 16px rgba(201, 165, 106, 0.2);
  background: #ece4d8;
  z-index: 3;
  display: flex;
  flex-direction: column;
}
.inset-photo {
  flex: 1;
  border-radius: 0;
  min-height: 0;
  box-shadow: none;
}
.inset-photo img {
  min-height: 0;
  height: 100%;
  width: 100%;
  object-fit: cover;
}
.inset-caption {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  width: 86%;
  padding: 5px 4px 6px;
  background: linear-gradient(180deg, rgba(245,236,222,0.92), #efe4d4);
  color: #2a221c;
  font-size: 9.5px;
  font-weight: 800;
  text-align: center;
  line-height: 1.3;
  z-index: 4;
  pointer-events: auto;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.18);
  letter-spacing: 0.02em;
}

/* Card 3 duo */
.duo-media {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 6px;
  align-items: stretch;
  padding: 2px 12px 12px;
}
.duo-item {
  position: relative;
  min-height: 124px;
}
.duo-item .img-slot {
  height: 100%;
  min-height: 124px;
  border-radius: 12px;
}
.duo-item .img-slot img { min-height: 124px; }
.duo-arrow {
  align-self: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(145deg, #f0dfc0, #c9a56a 60%, #a8874e);
  color: #2a1e10;
  font-weight: 900;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    0 2px 8px rgba(0,0,0,0.22),
    0 0 10px rgba(201, 165, 106, 0.35);
  padding-bottom: 1px;
}
.duo-tag {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  z-index: 3;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 999px;
  max-width: 94%;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.02em;
  box-shadow: 0 2px 8px rgba(0,0,0,0.22);
}
.duo-tag.dark {
  background: rgba(32, 26, 22, 0.82);
  color: #fff8ec;
  backdrop-filter: blur(4px);
}
.duo-tag.light {
  background: rgba(248, 241, 230, 0.94);
  color: #2a221c;
  border: 1px solid rgba(201, 165, 106, 0.45);
}

/* Card 4 tags */
.has-tags { position: relative; }
.tag-pills {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 14px;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  gap: 6px;
  pointer-events: none;
}
.pill {
  pointer-events: auto;
  background: linear-gradient(180deg, #fbf4e8, #ebd8b8);
  color: #2a221c;
  font-size: 10px;
  font-weight: 700;
  padding: 6px 10px;
  border-radius: 999px;
  box-shadow:
    0 3px 10px rgba(0,0,0,0.22),
    0 0 0 1px rgba(180, 140, 90, 0.25),
    inset 0 1px 0 rgba(255,255,255,0.65);
  white-space: nowrap;
  max-width: 34%;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  letter-spacing: 0.02em;
  position: relative;
}
.pill::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 1px;
  height: 14px;
  background: linear-gradient(180deg, rgba(180,140,90,0.55), transparent);
  transform: translateX(-50%);
  pointer-events: none;
}

/* Footer */
.mod-footer {
  padding: 4px 2px 2px;
}
.footer-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  background:
    radial-gradient(80% 120% at 50% 120%, rgba(212, 180, 131, 0.35), transparent 55%),
    linear-gradient(180deg, #3f362f 0%, #241e19 55%, #1a1512 100%);
  border: 1px solid rgba(212, 180, 131, 0.38);
  border-radius: 999px;
  padding: 13px 18px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.06),
    inset 0 -10px 22px rgba(201, 165, 106, 0.14),
    0 6px 18px rgba(0,0,0,0.3);
  overflow: hidden;
}
.footer-bar::after {
  content: "";
  position: absolute;
  left: 12%;
  right: 12%;
  bottom: -2px;
  height: 10px;
  background: radial-gradient(ellipse at center, rgba(232, 200, 130, 0.55), transparent 70%);
  pointer-events: none;
  filter: blur(2px);
}
.footer-seal {
  width: 28px;
  height: 28px;
  color: var(--gold-bright);
  flex-shrink: 0;
  display: flex;
  filter: drop-shadow(0 0 6px rgba(212, 180, 131, 0.35));
}
.footer-seal svg { width: 100%; height: 100%; }
.footer-sep {
  width: 1px;
  height: 22px;
  background: linear-gradient(180deg, transparent, rgba(240, 223, 192, 0.45), transparent);
  flex-shrink: 0;
}
.footer-slogan {
  margin: 0;
  flex: 1;
  font-size: 13.5px;
  font-weight: 700;
  color: #fff8ec;
  letter-spacing: 0.06em;
  line-height: 1.4;
  text-shadow: 0 1px 3px rgba(0,0,0,0.35);
}

/* Toast / exporting */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%);
  background: rgba(42, 36, 32, 0.95);
  color: #f5e6c8;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 100;
  border: 1px solid rgba(212, 180, 131, 0.4);
  box-shadow: 0 8px 24px rgba(0,0,0,0.35);
}
.exporting {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
}
.exporting[hidden] { display: none; }
.exporting-box {
  background: #2a2420;
  color: #f5e6c8;
  padding: 18px 28px;
  border-radius: 14px;
  border: 1px solid rgba(212, 180, 131, 0.4);
  font-weight: 600;
}

/* Narrow phones */
@media (max-width: 420px) {
  .card-body {
    grid-template-columns: 1fr;
  }
  .card-body:not(.card-body-stack) .card-text::after { display: none; }
  .card-media {
    padding: 0 10px 12px;
    min-height: 148px;
  }
  .card-media .img-slot,
  .card-media .img-slot img {
    min-height: 148px;
  }
  .main-title { font-size: 30px; letter-spacing: 0.14em; }
  .card-title { font-size: 15.5px; }
  .inset-circle { width: 92px; height: 92px; }
  .mid-chevron { left: 8px; top: 18px; transform: none; }
  .canvas { padding: 14px 10px 16px; }
  .card { margin-bottom: 8px; }
}
