/* ============================================================
   My Kind of Christmas Tree
   ============================================================ */
:root {
  --cream: #f9f3e6;
  --cream-2: #f2e8d5;
  --paper: #fffdf8;
  --pine: #17362a;
  --pine-2: #1f4a37;
  --gold: #c8a34a;
  --gold-2: #e3c87e;
  --ink: #1d2a24;
  --soft: #6f6656;
  --line: rgba(29, 42, 36, 0.12);
  --red: #b3402f;
  --shadow: 0 18px 40px -22px rgba(30, 40, 30, 0.45);
  --radius: 22px;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 50% -15%, #fffdf6 0%, rgba(255, 253, 246, 0) 60%),
    radial-gradient(900px 520px at 100% 100%, #efe0c4 0%, rgba(239, 224, 196, 0) 55%),
    var(--cream);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .35;
  background-image: radial-gradient(rgba(120, 100, 70, .18) 1px, transparent 1px);
  background-size: 22px 22px;
  z-index: 0;
}

body.no-scroll { overflow: hidden; }

.app {
  position: relative;
  z-index: 1;
  max-width: 520px;
  margin: 0 auto;
  padding: 0 18px 40px;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 2px 10px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(var(--cream) 62%, rgba(249, 243, 230, 0));
  backdrop-filter: blur(3px);
}

.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--pine);
  color: var(--gold-2);
  flex: none;
}
.brand-text {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  line-height: 1.25;
  color: var(--pine);
}

.top-actions { display: flex; align-items: center; gap: 8px; }

.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px;
  background: rgba(255, 253, 248, .7);
}
.lang-btn {
  border: 0; background: transparent;
  font: inherit; font-size: 11px; font-weight: 600;
  letter-spacing: .06em;
  padding: 5px 10px; border-radius: 999px;
  color: var(--soft); cursor: pointer;
}
.lang-btn.is-on { background: var(--pine); color: #fff8e8; }

.ghost-mini {
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, .8);
  color: var(--pine);
  font: inherit; font-size: 11px; font-weight: 600;
  padding: 6px 11px; border-radius: 999px; cursor: pointer;
}

/* ---------- screens ---------- */
.screen { display: none; animation: rise .45s ease both; }
.screen.is-active { display: block; }
@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.hero { padding: 18px 2px 6px; }

.eyebrow {
  margin: 0 0 12px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .26em;
  text-transform: uppercase;
  color: var(--gold);
}

.display {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 600;
  font-size: clamp(38px, 11.4vw, 52px);
  line-height: 1.02;
  letter-spacing: -.015em;
  margin: 0 0 16px;
  color: var(--pine);
}
.display em {
  font-style: italic;
  color: var(--red);
}

.hero-sub {
  margin: 0;
  font-size: 14.5px;
  color: var(--soft);
  max-width: 42ch;
}

.hero-art {
  display: grid;
  place-items: center;
  margin: 6px 0 4px;
}
.art-tree {
  width: min(300px, 76vw);
  height: auto;
  filter: drop-shadow(0 16px 24px rgba(30, 50, 35, .18));
}
.art-tree circle:nth-of-type(n+6) { animation: twinkle 2.6s ease-in-out infinite; }
.art-tree circle:nth-of-type(2n) { animation-delay: .8s; }
@keyframes twinkle {
  0%, 100% { opacity: .55; }
  50% { opacity: 1; }
}

.cta {
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 16px 22px;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .01em;
  background: linear-gradient(160deg, var(--pine-2), var(--pine));
  color: #fdf6e6;
  cursor: pointer;
  box-shadow: 0 14px 26px -14px rgba(23, 54, 42, .75);
  transition: transform .18s ease, box-shadow .18s ease;
}
.cta:hover { transform: translateY(-1px); }
.cta:active { transform: translateY(1px); }
.cta:disabled {
  opacity: .45;
  box-shadow: none;
  cursor: default;
  transform: none;
}

.micro {
  font-size: 11.5px;
  color: var(--soft);
  text-align: center;
  margin: 12px 0 0;
  line-height: 1.55;
}

.steps {
  margin: 30px 0 0;
  display: grid;
  gap: 14px;
}
.step { display: flex; gap: 12px; align-items: flex-start; }
.step-n {
  width: 26px; height: 26px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: 12px; font-weight: 600;
}
.step strong { display: block; font-size: 13.5px; font-weight: 600; color: var(--pine); }
.step p { margin: 2px 0 0; font-size: 12.5px; color: var(--soft); }

/* ---------- shared screen heads ---------- */
.screen-head { padding: 16px 2px 18px; }
.screen-head.tight { padding-bottom: 12px; }
.h2 {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 600;
  font-size: clamp(26px, 7.4vw, 32px);
  line-height: 1.14;
  margin: 0 0 8px;
  color: var(--pine);
}
.sub { margin: 0; font-size: 13.5px; color: var(--soft); max-width: 44ch; }

/* ---------- upload ---------- */
.drop {
  position: relative;
  border: 1.5px dashed rgba(23, 54, 42, .28);
  border-radius: var(--radius);
  background: rgba(255, 253, 248, .78);
  padding: 26px 18px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s ease, background .2s ease;
}
.drop:hover, .drop.is-drag {
  border-color: var(--pine);
  background: #fffdf6;
}
.drop-icon {
  display: grid; place-items: center;
  width: 48px; height: 48px; margin: 0 auto 10px;
  border-radius: 50%;
  background: var(--cream-2);
  color: var(--pine);
}
.drop strong { display: block; font-size: 14.5px; color: var(--pine); }
.drop small { display: block; margin-top: 3px; font-size: 11.5px; color: var(--soft); }

.thumbs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 9px;
  margin-top: 16px;
}
.thumb {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  overflow: hidden;
  background: var(--cream-2);
  border: 1px solid rgba(23, 54, 42, .08);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-badge {
  position: absolute; left: 6px; bottom: 6px;
  width: 20px; height: 20px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: rgba(23, 54, 42, .82);
  color: #fff5dc;
  font-size: 10px;
}
.thumb-x {
  position: absolute; right: 5px; top: 5px;
  width: 20px; height: 20px;
  border-radius: 50%; border: 0;
  background: rgba(255, 253, 248, .9);
  color: var(--pine);
  font-size: 13px; line-height: 1;
  cursor: pointer;
  display: grid; place-items: center;
  padding: 0;
}
.thumb-spin {
  position: absolute; inset: 0;
  background: rgba(249, 243, 230, .55);
  backdrop-filter: blur(1px);
}
.thumb-spin::after {
  content: '';
  position: absolute; left: 50%; top: 50%;
  width: 20px; height: 20px; margin: -10px 0 0 -10px;
  border: 2px solid rgba(23, 54, 42, .2);
  border-top-color: var(--pine);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.thumb-add {
  border: 1.5px dashed rgba(23, 54, 42, .25);
  background: transparent;
  display: grid; place-items: center;
  gap: 2px;
  cursor: pointer;
  color: var(--soft);
  font: inherit;
}
.thumb-add span { font-size: 20px; color: var(--pine); line-height: 1; }
.thumb-add small { font-size: 9.5px; letter-spacing: .02em; }

.count {
  margin: 10px 0 0;
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--soft);
  text-align: right;
}

.cut-status {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.5;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 253, 248, .85);
  border: 1px solid var(--line);
  color: var(--soft);
}
.cut-status.is-ok { border-color: rgba(47, 122, 82, .35); color: #276247; }
.cut-status.is-warn { border-color: rgba(179, 64, 47, .3); color: #8c3a2c; }

.linkbtn {
  border: 0; background: none; padding: 6px 0;
  font: inherit; font-size: 12px; font-weight: 600;
  color: var(--pine); text-decoration: underline; cursor: pointer;
}

.row-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 22px;
}
.row-actions .cta { flex: 1; }

.ghost {
  border: 1px solid rgba(23, 54, 42, .22);
  background: rgba(255, 253, 248, .7);
  color: var(--pine);
  border-radius: 999px;
  padding: 12px 16px;
  font: inherit; font-size: 13px; font-weight: 600;
  cursor: pointer;
}

/* ---------- editor ---------- */
.canvas-wrap {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  background: var(--paper);
  line-height: 0;
  position: relative;
}
#editorCanvas {
  width: 100%;
  height: auto;
  display: block;
  touch-action: none;
  cursor: grab;
}
#editorCanvas:active { cursor: grabbing; }

.tool-row {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 12px 2px 4px;
  scrollbar-width: none;
}
.tool-row::-webkit-scrollbar { display: none; }
.tool-row button {
  flex: none;
  border: 1px solid var(--line);
  background: rgba(255, 253, 248, .88);
  color: var(--pine);
  border-radius: 999px;
  padding: 9px 13px;
  font: inherit; font-size: 12.5px; font-weight: 600;
  cursor: pointer;
}
.tool-row button.is-on { background: var(--pine); color: #fff6e2; border-color: var(--pine); }
.tool-arrange { color: var(--gold) !important; }

.panel {
  margin-top: 16px;
  background: rgba(255, 253, 248, .82);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.field-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .13em;
  text-transform: uppercase;
  color: var(--soft);
  margin-bottom: 8px;
}
.lock-badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 9.5px; letter-spacing: .06em;
  color: var(--gold);
  cursor: pointer;
}

.theme-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 18px;
  scrollbar-width: none;
}
.theme-row::-webkit-scrollbar { display: none; }
.theme-chip {
  flex: none;
  display: inline-flex; align-items: center; gap: 7px;
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 999px;
  padding: 8px 12px;
  font: inherit; font-size: 12px; font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
}
.theme-chip.is-on {
  border-color: var(--pine);
  box-shadow: inset 0 0 0 1px var(--pine);
}
.theme-chip.is-locked { opacity: .68; }
.theme-dot {
  width: 12px; height: 12px; border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, .1);
}
.theme-lock { font-size: 10px; }

.field { display: block; margin-top: 14px; }
.field input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fffdf8;
  border-radius: 12px;
  padding: 12px 14px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
}
.field input:read-only { color: var(--soft); background: rgba(249, 243, 230, .6); }
.field input:focus { outline: 2px solid rgba(23, 54, 42, .28); outline-offset: 1px; }

/* ---------- result ---------- */
.preview-block { margin: 0 0 22px; }
.preview-label {
  display: block;
  font-size: 10.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--soft);
  margin-bottom: 8px;
}
.preview {
  width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.story-block { max-width: 74%; }

.save-grid { display: grid; gap: 10px; margin-top: 6px; }
.save-mini { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.save-mini .ghost { padding: 11px 8px; font-size: 12.5px; text-align: center; }
.save-mini:nth-of-type(3) { grid-template-columns: repeat(2, 1fr); }

.premium-card {
  margin-top: 26px;
  border-radius: var(--radius);
  padding: 22px 20px;
  background:
    radial-gradient(120% 120% at 0% 0%, rgba(227, 200, 126, .28), rgba(227, 200, 126, 0) 55%),
    linear-gradient(165deg, #1f4a37, #122a20);
  color: #f8efdc;
  box-shadow: 0 22px 44px -26px rgba(18, 42, 32, .9);
}
.premium-card h3 {
  font-family: 'Playfair Display', Georgia, serif;
  font-weight: 600;
  font-size: 23px;
  line-height: 1.2;
  margin: 10px 0 6px;
}
.premium-card p { margin: 0; font-size: 12.5px; color: rgba(248, 239, 220, .72); }
.premium-card ul {
  list-style: none;
  padding: 0;
  margin: 14px 0 18px;
  display: grid;
  gap: 7px;
}
.premium-card li {
  font-size: 12.5px;
  padding-left: 18px;
  position: relative;
  color: rgba(248, 239, 220, .92);
}
.premium-card li::before {
  content: '✦';
  position: absolute; left: 0; top: 0;
  color: var(--gold-2);
  font-size: 10px;
}
.premium-tag {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: .12em;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(227, 200, 126, .18);
  color: var(--gold-2);
  border: 1px solid rgba(227, 200, 126, .32);
}
.premium-price {
  display: flex; align-items: baseline; gap: 9px;
  margin: 0 0 14px;
  flex-wrap: wrap;
}
.premium-price s { font-size: 14px; color: rgba(248, 239, 220, .45); }
.premium-price strong {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 28px;
  color: #fff6e2;
}
.premium-price span { font-size: 11px; color: rgba(248, 239, 220, .6); }
.premium-card .cta {
  background: linear-gradient(160deg, #f4e3b8, #dcc078);
  color: #21301f;
  box-shadow: 0 14px 26px -16px rgba(0, 0, 0, .8);
}
.premium-card .micro { color: rgba(248, 239, 220, .55); }

.ad-slot { margin: 24px 0 6px; min-height: 60px; }


/* ---------- ornament gate ---------- */
.gate-sub { font-size: 13px; color: var(--soft); margin: 0 0 14px; line-height: 1.55; }
.gate-ad {
  position: relative;
  height: 120px;
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    radial-gradient(120% 120% at 20% 0%, rgba(227, 200, 126, .22), rgba(227, 200, 126, 0) 60%),
    #f7efdd;
  display: grid;
  place-items: center;
  overflow: hidden;
  margin: 0 0 14px;
}
.gate-ad .adsbygoogle { width: 100%; height: 120px; max-height: 120px; overflow: hidden; }
.gate-ad-label {
  position: absolute; top: 7px; left: 12px;
  font-size: 9px; letter-spacing: .16em; text-transform: uppercase;
  color: var(--soft); opacity: .8;
}
.gate-ad-fallback { font-size: 30px; color: var(--gold); opacity: .35; }
.gate-or {
  display: flex; align-items: center; gap: 10px;
  margin: 16px 0;
  color: var(--soft); font-size: 10.5px;
  letter-spacing: .1em; text-transform: uppercase;
}
.gate-or::before, .gate-or::after {
  content: ''; flex: 1; height: 1px; background: var(--line);
}
.ghost.wide { width: 100%; padding: 14px; font-size: 13.5px; }

/* ---------- cross promo ---------- */
.promo { margin: 26px 0 6px; }
.promo-title {
  font-size: 10.5px; letter-spacing: .18em; text-transform: uppercase;
  color: var(--soft); margin: 0 0 10px;
}
.promo-card {
  display: flex; align-items: center; gap: 12px;
  padding: 13px 14px;
  border-radius: 16px;
  background: #fffdf8;
  border: 1px solid var(--line);
  text-decoration: none;
  color: var(--ink);
  margin-bottom: 8px;
  box-shadow: 0 14px 26px -24px rgba(20, 40, 30, .8);
  transition: transform .16s ease, border-color .16s ease;
}
.promo-card:hover { transform: translateY(-1px); border-color: rgba(23, 54, 42, .3); }
.promo-ico {
  width: 38px; height: 38px; flex: none;
  border-radius: 12px;
  background: linear-gradient(160deg, var(--pine-2), var(--pine));
  color: var(--gold-2);
  display: grid; place-items: center;
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 15px;
}
.promo-body { display: flex; flex-direction: column; gap: 1px; flex: 1; min-width: 0; }
.promo-body strong { font-size: 13.5px; font-weight: 600; color: var(--pine); }
.promo-body small { font-size: 11.5px; color: var(--soft); }
.promo-arrow { color: var(--gold); font-size: 16px; flex: none; }

/* ---------- footer ---------- */
.site-foot {
  margin-top: 34px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  text-align: center;
}
.foot-title {
  font-size: 10.5px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--soft);
  margin: 0 0 10px;
}
.foot-links {
  display: flex; flex-wrap: wrap; justify-content: center;
  gap: 6px 14px;
  margin-bottom: 12px;
}
.foot-links a {
  color: var(--pine);
  font-size: 12px;
  text-decoration: none;
  border-bottom: 1px solid rgba(23, 54, 42, .18);
  padding-bottom: 1px;
}
.foot-legal {
  display: flex; justify-content: center; gap: 8px;
  color: var(--soft); font-size: 11px;
}
.foot-legal .linkbtn { font-size: 11px; color: var(--soft); font-weight: 500; }

/* ---------- modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(16, 28, 22, .55);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: end center;
  padding: 0;
  animation: fade .2s ease both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  overflow-y: auto;
  background: var(--paper);
  border-radius: 26px 26px 0 0;
  padding: 26px 20px calc(24px + env(safe-area-inset-bottom));
  position: relative;
  animation: slideUp .3s cubic-bezier(.2, .8, .2, 1) both;
}
@keyframes slideUp { from { transform: translateY(24px); } to { transform: none; } }

.modal-card h3 {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 24px;
  line-height: 1.2;
  margin: 10px 0 12px;
  color: var(--pine);
}
.modal-card ul { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 7px; }
.modal-card li { font-size: 13px; padding-left: 18px; position: relative; color: var(--ink); }
.modal-card li::before { content: '✦'; position: absolute; left: 0; color: var(--gold); font-size: 10px; }
.modal-card .premium-tag { background: rgba(200, 163, 74, .14); color: #8a6c22; border-color: rgba(200, 163, 74, .3); }
.modal-x {
  position: absolute; right: 14px; top: 12px;
  border: 0; background: none;
  font-size: 26px; line-height: 1;
  color: var(--soft); cursor: pointer;
  padding: 4px 8px;
}
.sheet-body { font-size: 13px; color: var(--soft); line-height: 1.65; margin: 0; }

.restore { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.restore-row { display: flex; gap: 8px; }
.restore-row input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit; font-size: 13px;
  background: #fffdf8;
}

/* ---------- busy ---------- */
.busy {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(249, 243, 230, .82);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
}
.busy-card {
  background: var(--paper);
  border-radius: 20px;
  padding: 24px 22px;
  box-shadow: var(--shadow);
  text-align: center;
  min-width: 220px;
}
.busy-card p { margin: 14px 0 0; font-size: 13px; color: var(--pine); }
.spinner {
  width: 30px; height: 30px; margin: 0 auto;
  border: 2.5px solid rgba(23, 54, 42, .16);
  border-top-color: var(--pine);
  border-radius: 50%;
  animation: spin .9s linear infinite;
}
.busy-track {
  margin-top: 12px; height: 4px; border-radius: 3px;
  background: var(--cream-2); overflow: hidden;
}
.busy-bar { height: 100%; width: 0%; background: var(--gold); transition: width .3s ease; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: 26px;
  transform: translate(-50%, 12px);
  background: rgba(23, 54, 42, .94);
  color: #fff6e2;
  font-size: 12.5px;
  padding: 11px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 90;
  max-width: 86vw;
  text-align: center;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 700px) {
  body { padding: 20px 0; }
  .app { padding-bottom: 60px; }
  .modal { place-items: center; padding: 24px; }
  .modal-card { border-radius: 26px; }
}
