/* Card maker (/card-maker) */
.cm-unlock-note { margin-top: 14px; font-size: .9rem; color: var(--muted); }
.cm-unlock-note a { color: var(--rose-700); font-weight: 600; }

.cm-step { padding-block: 34px; }
.cm-step[hidden] { display: none; }
.cm-step__head { display: flex; gap: 16px; align-items: flex-start; margin-bottom: 22px; }
.cm-step__head h2 { font-size: clamp(1.5rem, 3.4vw, 2rem); margin: 0 0 4px; }
.cm-step__num {
  flex: none; width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
  background: var(--grad-hot); color: #fff; font-weight: 700; box-shadow: var(--gloss), var(--sh-pink);
}

/* designs */
.cm-toolbar { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 18px; }
.cm-search { flex: 1 1 260px; max-width: 420px; }
.cm-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.cm-designs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.cm-design {
  display: flex; flex-direction: column; gap: 8px; text-align: left; padding: 8px; border-radius: var(--r-md);
  background: #fff; border: 2px solid transparent; box-shadow: var(--sh-sm); cursor: pointer; font: inherit; color: var(--ink);
  transition: transform .2s var(--ease), border-color .2s;
}
.cm-design:hover { transform: translateY(-3px); }
.cm-design:focus-visible { outline: 3px solid var(--rose-400); outline-offset: 2px; }
.cm-design.is-active { border-color: var(--rose-500); }
.cm-design__img { display: block; aspect-ratio: 4 / 5; border-radius: var(--r-sm); overflow: hidden; background: var(--rose-50); }
.cm-design__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cm-design__img { position: relative; }
.cm-design__badge {
  position: absolute; left: 6px; right: 6px; bottom: 6px; padding: 4px 8px; border-radius: 99px; text-align: center;
  font-size: .7rem; font-weight: 600; background: rgba(42,4,18,.78); color: #fff;
}
.cm-design__badge--ok { background: rgba(31,122,74,.88); }
.cm-design.is-locked { cursor: not-allowed; }
.cm-design.is-locked .cm-design__img img { filter: grayscale(.6) brightness(.85); }
.cm-design.is-locked:hover { transform: none; }
.cm-unlocked { display: grid; gap: 10px; }
.cm-unlocked[hidden], .cm-create[hidden], [data-unlock-form][hidden], .cm-etsy[hidden], .cm-buy[hidden] { display: none; }
/* Copy protection: no selecting, long-press saving or dragging of the preview and design pictures. */
.cm-stage, .cm-stage canvas, .cm-designs img {
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-user-drag: none;
}
.cm-design__title { font-size: .84rem; font-weight: 600; line-height: 1.3; }
.cm-design__sub { font-size: .74rem; color: var(--muted); }
.cm-design--own { justify-content: center; align-items: center; text-align: center; background: var(--grad-blush); border: 2px dashed var(--rose-300); min-height: 200px; }
.cm-design__own-icon { font-size: 2.2rem; color: var(--rose-600); line-height: 1; }

/* editor */
.cm-editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(300px, 400px); gap: 26px; align-items: start; }
.cm-stage-col { position: sticky; top: calc(var(--nav-h) + 12px); display: grid; gap: 10px; justify-items: center; }
.cm-stage {
  position: relative; width: 100%; max-width: min(100%, calc((100vh - var(--nav-h) - 150px) * var(--cm-ar, .5625)));
  max-height: calc(100vh - var(--nav-h) - 150px); border-radius: var(--r-md); overflow: hidden; background: #1b0710; box-shadow: var(--sh-lg);
}
.cm-stage canvas { display: block; width: 100%; height: 100%; touch-action: pan-y; cursor: grab; }
.cm-stage canvas:focus-visible { outline: 3px solid var(--rose-400); outline-offset: -3px; }
.cm-stage__loading { position: absolute; inset: 0; display: grid; place-items: center; color: #fff; background: rgba(27,7,16,.6); }
.cm-stage__loading[hidden] { display: none; }
.cm-transport { display: flex; gap: 10px; align-items: center; width: 100%; max-width: 560px; }
.cm-scrub { flex: 1; accent-color: var(--rose-500); }
.cm-time { font-variant-numeric: tabular-nums; font-size: .82rem; color: var(--muted); min-width: 86px; text-align: right; }
.cm-iconbtn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer; font-size: 1rem;
  background: var(--grad-hot); color: #fff; box-shadow: var(--gloss);
}
.cm-design-name { font-size: .86rem; color: var(--muted); text-align: center; }

.cm-panel { display: grid; gap: 16px; }
.cm-box { background: #fff; border-radius: var(--r-md); padding: 18px; box-shadow: var(--sh-sm); display: grid; gap: 12px; }
.cm-box[hidden] { display: none; }
.cm-box__head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.cm-box__head h3 { font-size: 1.15rem; margin: 0; }
.cm-box__actions { display: flex; gap: 8px; }
.cm-filebtn { cursor: pointer; }
.cm-filebtn[aria-disabled="true"] { opacity: .5; }
.cm-layers { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 180px; overflow: auto; }
.cm-layer {
  width: 100%; text-align: left; padding: 8px 12px; border-radius: var(--r-sm); border: 1px solid var(--rose-200);
  background: var(--rose-50); font: inherit; font-size: .88rem; color: var(--ink); cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cm-layer.is-active { border-color: var(--rose-500); background: var(--rose-100); font-weight: 600; }
.cm-hint { font-size: .85rem; }
[data-layer-form] { display: grid; gap: 12px; }
.cm-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 10px; }
.cm-field--colour input[type="color"] { width: 100%; height: 46px; border: 1px solid var(--rose-200); border-radius: var(--r-sm); background: #fff; padding: 4px; cursor: pointer; }
.cm-textarea { min-height: 80px; }
.cm-toggles { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; }
.cm-toggles input[type="color"] { width: 34px; height: 28px; border: 0; padding: 0; background: none; }
.cm-check { display: inline-flex; gap: 8px; align-items: center; font-size: .88rem; cursor: pointer; }
.cm-check[hidden] { display: none; }
.cm-check input { accent-color: var(--rose-500); width: 17px; height: 17px; }
.cm-align { display: flex; gap: 6px; }
.cm-align .chip { padding: 6px 14px; font-size: .78rem; }
.cm-layer-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.cm-danger { color: #b3123f !important; }
.cm-panel input[type="range"] { width: 100%; accent-color: var(--rose-500); }
.cm-copyright {
  font-size: .8rem; line-height: 1.55; padding: 12px 14px; border-radius: var(--r-sm);
  background: #fff7e6; border: 1px solid var(--gold-light); color: #5a3a06;
}
.cm-music-name { font-weight: 600; font-size: .9rem; word-break: break-all; }
[data-music-info] { display: grid; gap: 10px; }
[data-music-info][hidden] { display: none; }
.field[hidden] { display: none; }

/* create */
.cm-create, .cm-progress, .cm-result, .cm-made-for-you { padding: 24px; margin-bottom: 18px; display: grid; gap: 14px; }
.cm-progress[hidden], .cm-result[hidden] { display: none; }
.cm-code-input { font-family: ui-monospace, Consolas, monospace; font-size: 1.15rem; letter-spacing: .08em; text-transform: uppercase; }
.cm-msg { font-size: .9rem; min-height: 1.2em; margin-top: 10px; }
.cm-msg.is-ok { color: #1f7a4a; }
.cm-msg.is-error { color: #c0183f; }
.cm-etsy { border-top: 1px solid var(--rose-100); padding-top: 14px; }
.cm-etsy summary { cursor: pointer; font-weight: 600; color: var(--rose-700); }
.cm-etsy form { display: grid; gap: 12px; margin-top: 14px; }
.cm-buy { font-size: .88rem; color: var(--muted); }
.cm-buy a, .cm-legal a { color: var(--rose-700); }
.cm-bar { height: 12px; border-radius: 99px; background: var(--rose-100); overflow: hidden; }
.cm-bar span { display: block; height: 100%; width: 0; background: var(--grad-hot); transition: width .2s linear; }
.cm-progress__pct { font-variant-numeric: tabular-nums; font-weight: 600; }
/* Sized to the video itself (no letterbox bars): shrink to fit both ways, keep its shape. */
.cm-result video { display: block; width: auto; height: auto; max-width: 100%; max-height: 70vh; margin-inline: auto; border-radius: var(--r-md); background: transparent; }
.cm-result__actions { display: flex; gap: 12px; flex-wrap: wrap; }
.cm-result__note { font-size: .85rem; }
.cm-link { border-top: 1px solid var(--rose-100); padding-top: 16px; display: grid; gap: 10px; }
.cm-link h4 { font-size: 1.05rem; margin: 0; }
.cm-link form { display: grid; gap: 10px; }
.cm-link form[hidden], [data-link-result][hidden], [data-voice-info][hidden] { display: none; }
[data-link-result], [data-voice-info] { display: grid; gap: 10px; }
.cm-link__row { display: flex; gap: 8px; }
.cm-link__row .input { flex: 1; min-width: 0; font-size: .85rem; }
.cm-made-for-you { background: var(--grad-blush); box-shadow: none; }
.cm-made-for-you h3, .cm-create h3, .cm-result h3, .cm-progress h3 { font-size: 1.2rem; margin: 0; }
.cm-legal { font-size: .78rem; line-height: 1.6; margin-top: 8px; }

/* editor panel: tabs, words list, fonts, colours */
.cm-stage-hint { font-size: .76rem; color: var(--muted); text-align: center; margin: 0; }
.cm-stage-hint[hidden] { display: none; }
.cm-design-row { display: flex; gap: 10px; align-items: center; justify-content: center; flex-wrap: wrap; }
.cm-design-row .cm-design-name { margin: 0; }
.cm-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px; }
.cm-tabs::-webkit-scrollbar { display: none; }
.cm-tab {
  flex: none; padding: 10px 14px; border-radius: 99px; border: 1px solid var(--rose-200); background: #fff;
  font: 600 .84rem var(--font-ui); color: var(--plum-800); cursor: pointer; white-space: nowrap;
}
.cm-tab.is-active { background: var(--grad-hot); color: #fff; border-color: transparent; box-shadow: var(--gloss); }
.cm-tab[hidden] { display: none; }
.cm-add-row { display: flex; gap: 8px; flex-wrap: wrap; }
.cm-mobile-change { display: none; }
.cm-layers { display: flex; flex-wrap: wrap; gap: 6px; max-height: none; overflow: visible; }
.cm-layers li { min-width: 0; }
.cm-layer { width: auto; max-width: 220px; border-radius: 99px; padding: 8px 14px; }
.cm-fonts { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; }
.cm-font {
  height: 46px; border-radius: var(--r-sm); border: 1px solid var(--rose-200); background: #fff; color: var(--ink);
  font-size: 1.3rem; cursor: pointer; line-height: 1;
}
.cm-font.is-active { border: 2px solid var(--rose-500); background: var(--rose-50); }
.cm-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.cm-swatch {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid #fff; background: var(--sw);
  box-shadow: 0 0 0 1px var(--rose-200); cursor: pointer; padding: 0; position: relative; overflow: hidden;
}
.cm-swatch.is-active { box-shadow: 0 0 0 3px var(--rose-500); }
.cm-swatch--custom { background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red); display: inline-block; }
.cm-swatch--custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.cm-info {
  position: absolute; right: 8px; bottom: 8px; width: 26px; height: 26px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255,255,255,.75); color: var(--plum-900); font: italic 700 .9rem Georgia, serif; line-height: 26px; padding: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.25); opacity: .8;
}
.cm-info:hover, .cm-info[aria-expanded="true"] { opacity: 1; }
.cm-info__pop {
  position: absolute; right: 8px; bottom: 40px; max-width: 80%; padding: 8px 12px; border-radius: 10px;
  background: rgba(255,255,255,.95); color: var(--ink); font-size: .78rem; box-shadow: var(--sh-md);
}
.cm-info__pop[hidden] { display: none; }
.cm-help { background: var(--rose-50); border: 1px solid var(--rose-200); border-radius: var(--r-sm); padding: 10px 14px; }
.cm-help summary { cursor: pointer; font-weight: 600; color: var(--rose-700); font-size: .9rem; }
.cm-help ol { margin: 10px 0 2px; padding-left: 20px; display: grid; gap: 7px; font-size: .86rem; line-height: 1.5; }
.cm-request { display: grid; gap: 16px; margin-top: 6px; }
.cm-request[hidden], .cm-request-done[hidden], [data-made-for-you][hidden] { display: none; }
.cm-request fieldset { border: 1px solid var(--rose-200); border-radius: var(--r-sm); padding: 14px; margin: 0; display: grid; gap: 12px; background: rgba(255,255,255,.6); }
.cm-request legend { font-weight: 700; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--plum-800); padding: 0 6px; }
.cm-request .cm-check { display: flex; margin: 4px 0; }
.cm-request__code { margin: 0; font-size: .9rem; }
.cm-request-done { background: #fff; border-radius: var(--r-sm); padding: 14px; }
.cm-voice-mode { display: flex; gap: 6px; flex-wrap: wrap; }
[data-voice-pane] { display: grid; gap: 12px; }
[data-voice-pane][hidden] { display: none; }
.cm-rec { display: flex; gap: 16px; align-items: center; }
.cm-rec__btn {
  flex: none; width: 72px; height: 72px; border-radius: 50%; border: 4px solid #fff; cursor: pointer;
  background: #e0183c; color: #fff; font-size: 1.6rem; box-shadow: 0 0 0 2px #e0183c, var(--sh-md);
}
.cm-rec__btn.is-recording { animation: cm-rec-pulse 1.2s ease-in-out infinite; font-size: 1.3rem; }
@keyframes cm-rec-pulse { 50% { box-shadow: 0 0 0 10px rgba(224,24,60,.2), var(--sh-md); } }
.cm-rec__state { margin: 0; font-size: .9rem; }
.cm-rec__time { margin: 4px 0 0; font-variant-numeric: tabular-nums; color: var(--muted); font-size: .85rem; }
.cm-more { border-top: 1px solid var(--rose-100); padding-top: 10px; }
.cm-more summary { cursor: pointer; font-weight: 600; color: var(--rose-700); font-size: .88rem; padding: 4px 0; }
.cm-more__body { display: grid; gap: 12px; margin-top: 10px; }

@media (max-width: 860px) {
  .cm-editor { grid-template-columns: 1fr; gap: 14px; }
  .cm-editor-intro { display: none; }
  /* The card stays pinned at the top while you edit underneath it, so every
     change (and every letter you type) shows straight away. */
  .cm-stage-col {
    position: sticky; top: calc(var(--nav-h) + var(--sat, 0px)); z-index: 5; gap: 6px; padding: 8px 10px 10px;
    background: #fff7fb; border-radius: 0 0 var(--r-md) var(--r-md); box-shadow: 0 10px 18px -14px rgba(94,6,40,.45);
  }
  .cm-stage-col .cm-design-row { display: none; }
  .cm-panel .cm-mobile-change { display: inline-flex; }
  .cm-stage { max-height: 34svh; max-width: min(100%, calc(34svh * var(--cm-ar, .5625))); }
  .cm-stage-hint { display: none; }
  /* Keyboard open: a much smaller card and no play bar, so the box you're
     typing in always has room under it. */
  .cm-editor.is-typing .cm-stage { max-height: 20svh; max-width: min(100%, calc(20svh * var(--cm-ar, .5625))); }
  .cm-editor.is-typing .cm-transport { display: none; }
  /* Typing anything other than the card's own words (voice, music, sharing):
     the card doesn't need to stay in view, so it stops being pinned. */
  .cm-editor.is-typing:not(.is-typing-words) .cm-stage-col { position: static; }
  .cm-transport { gap: 8px; }
  .cm-iconbtn { width: 36px; height: 36px; }
  .cm-time { min-width: 0; font-size: .74rem; }
  .cm-design-row .cm-design-name { display: none; }
  .cm-design-row .btn { padding: 6px 14px; }
  .cm-panel { padding-bottom: 90px; }
  .cm-box { padding: 14px; }
  /* iPhone zooms into any text box smaller than 16px: keep them at 16px. */
  .cm .input, .cm .textarea, .cm .select { font-size: 16px; }
}
