/* Supertarra Tarraeditori 2 */
.st-editor, .st-preview {
  --st-accent: #5476e8;
  --st-accent-ink: #fff;
  --st-line: #e3e5ea;
  --st-ink: #1d1f24;
  --st-muted: #6b7180;
  --st-radius: 999px;
}

/* ---------- Esikatselu ---------- */
.st-preview { width: 100%; }
.st-preview--inline { margin-bottom: 24px; }
/* Valmiiksi tulostettu esikatselu editorissa: piiloon, jos sivulla on [supertarra_preview]-paikka */
body:has([data-supertarra-preview]) .st-preview--ssr { display: none; }
.st-preview__frame {
  /* Alueen kuvasuhde tuoteasetuksista (oletus = tarran oma). Muokattavissa teeman CSS:llä. */
  position: relative; width: 100%; max-width: 720px; margin: 0 auto;
  aspect-ratio: var(--st-box, var(--st-ratio, 1));
}
@media (max-width: 600px) {
  .st-preview__frame { aspect-ratio: var(--st-box-m, var(--st-box, var(--st-ratio, 1))); }
}
.st-preview__frame img {
  /* Tarra sovitetaan alueen sisään (contain) reunatilan verran sisennettynä */
  position: absolute; top: var(--st-pad, 0%); left: var(--st-pad, 0%);
  width: calc(100% - 2 * var(--st-pad, 0%)); height: calc(100% - 2 * var(--st-pad, 0%));
  display: block; object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.08)) drop-shadow(0 6px 18px rgba(0,0,0,.08));
  transition: opacity .15s ease;
  user-select: none;
}
.st-preview__frame.is-loading img { opacity: .82; }
.st-preview__spinner {
  position: absolute; right: 10px; top: 10px; width: 18px; height: 18px;
  border: 2px solid var(--st-line); border-top-color: var(--st-accent); border-radius: 50%;
  opacity: 0; transition: opacity .15s; animation: st-spin .7s linear infinite;
}
.st-preview__frame.is-loading .st-preview__spinner { opacity: 1; transition-delay: .25s; }
.st-preview__error {
  position: absolute; left: 50%; bottom: -34px; transform: translateX(-50%);
  font-size: 13px; color: #b42318; white-space: nowrap;
}
@keyframes st-spin { to { transform: rotate(360deg); } }

/* ---------- Editori ---------- */
.st-editor { color: var(--st-ink); margin-bottom: 24px; }
.st-section { margin-bottom: 18px; }
.st-heading { font-size: 1.15em; font-weight: 600; margin: 6px 0 10px; }
.st-label { font-size: 1em; margin: 0 0 8px; color: var(--st-ink); }

.st-text { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 10px; }
.st-text input, .st-field input {
  width: 100%; box-sizing: border-box; height: 52px; padding: 0 16px;
  border: 1px solid var(--st-line); border-radius: 10px; font-size: 16px; background: #fff; color: var(--st-ink);
}
.st-text input:focus { outline: none; border-color: var(--st-accent); box-shadow: 0 0 0 3px rgba(84,118,232,.15); }
.st-form-error { color: #b42318; font-size: 14px; margin: -2px 0 10px; }

.st-pills {
  display: inline-flex; flex-wrap: nowrap; gap: 2px; padding: 3px;
  border: 1px solid var(--st-line); border-radius: var(--st-radius); background: #fff; max-width: 100%;
}
.st-pill {
  appearance: none; border: 0; background: transparent; color: var(--st-ink); cursor: pointer;
  padding: 8px 16px; border-radius: var(--st-radius); font-size: 16px; line-height: 1.2; white-space: nowrap;
}
.st-pill:hover { background: #f2f4f8; }
.st-pill__img {
  display: inline-block; vertical-align: middle; height: 1.4em; margin: -0.1em 0;
  background: currentColor;
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%; mask-size: 100% 100%;
}
.st-pill.is-active { background: var(--st-accent); color: var(--st-accent-ink); }
.st-pill:focus-visible, .st-swatch:focus-visible, .st-icon:focus-visible, .st-arrow:focus-visible {
  outline: 2px solid var(--st-accent); outline-offset: 2px;
}

/* Vieritettävät rivit nuolilla */
.st-editor, .st-section { min-width: 0; max-width: 100%; }
.st-scroller {
  /* contain + width:0-track: vieritettävä sisältö ei saa levittää sarakkeita (Breakdance grid/flex) */
  contain: inline-size; width: 100%; max-width: 100%; box-sizing: border-box;
  position: relative; display: flex; align-items: center;
  border: 1px solid var(--st-line); border-radius: var(--st-radius); background: #fff; padding: 3px 0;
}
.st-scroller__track {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  padding: 3px 4px; flex: 1 1 0; width: 0; min-width: 0;
}
.st-scroller__track::-webkit-scrollbar { display: none; }
.st-arrow {
  appearance: none; flex: none; width: 28px; height: 36px; border: 0; background: transparent;
  font-size: 26px; line-height: 1; color: var(--st-ink); cursor: pointer; padding: 0;
}
.st-arrow:hover:not(:disabled) { color: var(--st-accent); }
.st-arrow:disabled { opacity: .25; cursor: default; }

/* Otsikkorivi: otsikko vasemmalla, nuolet oikealla */
.st-section__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.st-arrows { display: flex; gap: 2px; margin: -4px -4px 4px 0; }
.st-arrows .st-arrow {
  width: 32px; height: 32px; border-radius: 50%; font-size: 24px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center; padding: 0 0 3px;
}
.st-arrows .st-arrow:hover:not(:disabled) { background: #f2f4f8; }
.st-track {
  contain: inline-size; width: 100%; box-sizing: border-box;
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  border: 1px solid var(--st-line); border-radius: var(--st-radius); background: #fff; padding: 6px 8px;
}
.st-track::-webkit-scrollbar { display: none; }
.st-track.st-bgimgs--round { padding: 6px 8px; }

/* Tekstikenttä + merkkilaskuri */
.st-field { position: relative; min-width: 0; }
.st-field input.has-count { padding-right: 52px; }
.st-count {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--st-muted); font-variant-numeric: tabular-nums; pointer-events: none;
}
.st-count.is-full { color: var(--st-accent); font-weight: 600; }

/* Muistetun nimen ehdotus */
.st-suggest {
  appearance: none; display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  margin: 0 0 8px; padding: 6px 12px; border: 1px dashed var(--st-accent); border-radius: var(--st-radius);
  background: rgba(84,118,232,.06); color: var(--st-ink); font-size: 14px; cursor: pointer;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.st-suggest:hover { background: rgba(84,118,232,.12); }
.st-suggest__label { color: var(--st-muted); }
.st-scroller--tabs { border: 0; padding: 0; }
.st-scroller--tabs .st-arrow { display: none; }
.st-scroller--tabs .st-scroller__track { padding: 0; }
.st-scroller--tabs .st-pills { flex: none; }

.st-swatch {
  appearance: none; flex: none; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; padding: 0;
  border: 1px solid rgba(0,0,0,.12); background-size: cover; background-position: center;
}
.st-swatch.is-active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--st-accent); }

.st-icons .st-scroller__track { gap: 8px; }
.st-icon {
  appearance: none; flex: none; width: 84px; height: 84px; padding: 6px; cursor: pointer;
  border: 1px solid var(--st-line); border-radius: 8px; background: #fff;
}
.st-icon img { width: 100%; height: 100%; object-fit: contain; display: block; }
.st-more { flex: 0 0 1px; width: 1px; height: 1px; align-self: center; }
.st-icons--grid .st-more { grid-column: 1 / -1; width: auto; }
.st-icon.is-active { border-color: var(--st-accent); box-shadow: 0 0 0 1px var(--st-accent); }
.st-icons.st-scroller { border-radius: 10px; }
.st-icons--grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px;
  max-height: 420px; overflow-y: auto; padding: 8px; border: 1px solid var(--st-line); border-radius: 10px;
}
.st-icons--grid .st-icon { width: auto; height: auto; aspect-ratio: 1; }
.st-expand {
  display: block; margin: 10px 0 0 auto; appearance: none; border: 0; background: none;
  color: var(--st-accent); cursor: pointer; font-size: 16px; padding: 4px 0;
}

/* Ei kuvaketta -laatta */
.st-icon--none { display: flex; align-items: center; justify-content: center; color: var(--st-muted); font-size: 13px; line-height: 1.2; text-align: center;
  background: repeating-linear-gradient(135deg, #fff 0 6px, #f4f5f8 6px 12px); }
.st-icon--none.is-active { color: var(--st-accent); }

/* Taustakuvat */
.st-bgimg {
  appearance: none; flex: none; padding: 0; cursor: pointer; overflow: hidden; background: #f2f4f8;
  border: 1px solid var(--st-line); border-radius: 8px;
}
.st-bgimg img { width: 100%; height: 100%; object-fit: cover; display: block; }
.st-bgimg.is-active { border-color: var(--st-accent); box-shadow: 0 0 0 2px var(--st-accent); }
.st-bgimgs--grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px;
  max-height: 300px; overflow-y: auto; padding: 8px; border: 1px solid var(--st-line); border-radius: 10px;
}
.st-bgimgs--round .st-bgimg { width: 52px; height: 52px; border-radius: 50%; }
.st-bgimgs--round .st-bgimg.is-active { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--st-accent); }

/* Pyöreä esikatselu: rajataan kehys ympyrän kokoiseksi isoilla näytöillä */
.st-preview__frame--circle { max-width: 520px; }

@media (max-width: 600px) {
  .st-swatch { width: 38px; height: 38px; }
  .st-icon { width: 70px; height: 70px; }
  .st-pill { padding: 8px 12px; font-size: 15px; }
}

/* ---------- Kori, kassa, sähköpostit, oma tili ---------- */
.supertarra-edit { margin-top: 4px; font-size: 0.9em; }
.supertarra-thumb { display: inline-block; }
.supertarra-thumb img, img.supertarra-thumb {
  width: 100%; height: auto !important; max-width: 160px; object-fit: contain !important;
  aspect-ratio: auto !important; background: transparent;
}
.supertarra-thumb { cursor: zoom-in; }
