:root {
  --paper: #f5f6f8;
  --panel: #fbfbfc;
  --ink: #1c2128;
  --muted: #5f6773;
  --line: #d5d9df;
  --warn: #8a4b08;
  --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 var(--ui);
  -webkit-font-smoothing: antialiased;
}

.layout { min-height: 100svh; }

/* Bühne */
.stage {
  position: relative;
  height: 58svh;
  min-height: 320px;
  max-height: 640px;
  background: radial-gradient(120% 90% at 50% 40%, #ffffff 0%, #eef0f3 55%, #dde1e6 100%);
}

model-viewer {
  width: 100%;
  height: 100%;
  background: transparent;
  --poster-color: transparent;
  outline: none;
}

.loading[hidden] { display: none; }

.loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  margin: 0;
  color: var(--muted);
  pointer-events: none;
}

.views {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.views button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  min-height: 36px;
  background: transparent;
  color: var(--ink);
  font: 500 14px/1 var(--ui);
  cursor: pointer;
}

.views button[aria-pressed="true"] {
  background: var(--ink);
  color: #fff;
}

.zoom {
  position: absolute;
  right: 12px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.zoom[hidden] { display: none; }
.zoom-step {
  appearance: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}
.zoom-step svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}
.zoom-step:disabled { color: #b9bec5; cursor: default; }
.zoom-step:focus-visible { outline: 2px solid var(--ink); outline-offset: -2px; }
.zoom-track {
  position: relative;
  width: 30px;
  height: 84px;
  margin: 2px 0;
  cursor: pointer;
  outline: none;
}
.zoom-track::before,
.zoom-fill {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 7px;
  width: 2px;
  margin-left: -1px;
  border-radius: 1px;
}
.zoom-track::before {
  top: 7px;
  background: var(--line);
}
.zoom-fill {
  height: calc(var(--z, 0) * (100% - 14px));
  background: var(--ink);
}
.zoom-thumb {
  position: absolute;
  left: 50%;
  bottom: calc(7px + var(--z, 0) * (100% - 14px));
  width: 14px;
  height: 14px;
  margin: 0 0 -7px -7px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 2px #fff;
}
.zoom-track:focus-visible .zoom-thumb { outline: 2px solid var(--ink); outline-offset: 2px; }
@media (hover: hover) {
  .zoom-step:not(:disabled):hover { background: rgba(28, 33, 40, 0.07); }
}

.drag-hint {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.86);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  box-shadow: 0 2px 10px rgba(28, 33, 40, 0.08);
  color: var(--ink);
  pointer-events: none;
  opacity: 1;
  animation: drag-hint-in 0.4s ease backwards;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.drag-hint[hidden] { display: none; }
.drag-hint.is-off {
  opacity: 0;
  transform: scale(0.85);
}
@keyframes drag-hint-in {
  from { opacity: 0; transform: scale(0.85); }
}
.drag-hint svg {
  width: 24px;
  height: 24px;
  overflow: visible;
}
.drag-hint__hand {
  transform-box: fill-box;
  transform-origin: 40% 90%;
  animation: drag-hint-hand 2.4s ease-in-out infinite;
}
.drag-hint__arrows { animation: drag-hint-arrows 2.4s ease-in-out infinite; }
@keyframes drag-hint-hand {
  0%, 100% { transform: translateX(-2.2px) rotate(-9deg); }
  50% { transform: translateX(2.2px) rotate(9deg); }
}
@keyframes drag-hint-arrows {
  0%, 100% { opacity: 0.55; }
  25%, 75% { opacity: 1; }
}

/* Bedienfeld */
.panel {
  max-width: 520px;
  margin: 0 auto;
  padding: 24px 20px 40px;
}

.product {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

h1 {
  margin: 0 0 16px;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.engraving { margin-bottom: 18px; }

fieldset {
  margin: 0 0 28px;
  padding: 0;
  border: 0;
  min-width: 0;
}

legend,
.engraving label {
  display: block;
  margin: 0 0 10px;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.swatches {
  display: flex;
  gap: 10px;
}

.swatch {
  appearance: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: 500 14px/1.2 var(--ui);
  cursor: pointer;
  min-width: 0;
  text-align: center;
  hyphens: manual;
}

.swatch[aria-pressed="true"] {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.disc {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.14);
}
.disc--silber { background: radial-gradient(circle at 34% 30%, #ffffff 0%, #dadde1 34%, #9da2a9 72%, #e6e8eb 100%); }
.disc--gold { background: radial-gradient(circle at 34% 30%, #fff5d6 0%, #e9c679 34%, #af8130 72%, #edd8a2 100%); }
.disc--schwarz { background: radial-gradient(circle at 34% 30%, #8d9095 0%, #3b3d41 34%, #141516 72%, #4b4d51 100%); }
.stones .disc { width: 26px; height: 26px; margin: 4px 0; }
.disc--ohne { background: transparent; box-shadow: inset 0 0 0 1.5px #c3c8cf; }
.disc--lapis { background: radial-gradient(circle at 34% 30%, #6f86e8 0%, #2a3f9e 36%, #15226a 72%, #3b4fa8 100%); }
.disc--smaragd { background: radial-gradient(circle at 34% 30%, #9ff0c0 0%, #1f9a5c 38%, #0b5a33 74%, #2c8a58 100%); }
.disc--perlmutt { background: radial-gradient(circle at 34% 30%, #ffffff 0%, #f1ece6 30%, #d9e6ee 55%, #efe2ea 78%, #e6e9e2 100%); }

.label-hint {
  color: #8a919c;
  font-weight: 400;
}

textarea {
  display: block;
  width: 100%;
  min-height: 100px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font: 17px/1.4 "Gravur Symbole", var(--ui);
  resize: none;
}

.field { position: relative; }
.field textarea { padding-bottom: 30px; }
.field .count {
  position: absolute;
  right: 13px;
  bottom: 9px;
  font-size: 12px;
  pointer-events: none;
}

.fonts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.font-option {
  appearance: none;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 52px;
  padding: 6px 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  font: 500 12.5px/1.2 var(--ui);
  cursor: pointer;
}
.font-sample {
  font-size: 22px;
  font-weight: 400;
  font-synthesis: none;
  line-height: 1.1;
}
.font-option[data-font="schreibschrift"] .font-sample { font-size: 27px; line-height: 1; }
.font-option[data-font="druckschrift"] .font-sample { font-size: 20px; }

.font-option[aria-pressed="true"] {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.font-option:disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.font-note {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}
.font-note[hidden] { display: none; }

textarea::placeholder { color: #9aa1ab; }

.group-label {
  margin: 16px 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
}

.symbols {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.symbol {
  appearance: none;
  display: grid;
  place-items: center;
  min-width: 0;
  height: 46px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.symbol svg {
  width: 32px;
  height: 24px;
  fill: currentColor;
}

@media (hover: hover) {
  .symbol:hover { border-color: #aab1bb; }
}
.symbol:active { background: #eef0f3; }

.count {
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.count.is-full { color: var(--warn); }

.hint {
  margin: 8px 0 0;
  color: var(--warn);
  font-size: 13px;
  line-height: 1.4;
}
.hint:empty { display: none; }

.note {
  margin: 24px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.noscript {
  padding: 24px;
  text-align: center;
}

button:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

textarea:focus { border-color: var(--ink); }

/* Breite Bildschirme */
@media (min-width: 880px) {
  .layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 400px;
    height: 100svh;
  }
  .stage {
    height: 100svh;
    max-height: none;
  }
  .panel {
    max-width: none;
    margin: 0;
    padding: clamp(16px, 3svh, 40px) 36px clamp(12px, 2.4svh, 32px);
    overflow-y: auto;
    border-left: 1px solid var(--line);
    background: var(--panel);
  }
  h1 {
    margin-bottom: clamp(10px, 2svh, 22px);
    font-size: 22px;
  }
  .engraving { margin-bottom: clamp(12px, 2svh, 20px); }
  fieldset { margin-bottom: clamp(12px, 2.2svh, 24px); }
  .group-label { margin-top: clamp(8px, 1.6svh, 16px); }
  .note { margin-top: clamp(6px, 1.4svh, 20px); }
}

@media (min-width: 880px) and (max-height: 820px) {
  legend,
  .engraving label { margin-bottom: 7px; }
  .group-label { margin-bottom: 6px; }
  textarea { line-height: 1.3; }
  .field textarea { padding-top: 10px; padding-bottom: 24px; }
  .font-option { min-height: 42px; }
  .symbol { height: 38px; }
  .swatch { padding: 8px 6px 7px; gap: 5px; line-height: 1.05; }
  .disc { width: 24px; height: 24px; }
  .stones .disc { width: 22px; height: 22px; margin: 3px 0; }
}

/* Im Shop eingebettet (?embed=1) */
html.is-embed,
.is-embed body {
  height: 100%;
  background: transparent;
}
.is-embed .layout {
  display: block;
  height: 100%;
  min-height: 0;
}
.is-embed .stage {
  height: 100%;
  min-height: 0;
  max-height: none;
  background: var(--embed-bg, transparent);
}
.is-embed .panel,
.is-embed noscript { display: none; }
.is-embed .views,
.is-embed .zoom { bottom: 12px; }
.is-embed .loading { font-size: 13px; }

@media (max-height: 300px) {
  .is-embed .views,
  .is-embed .zoom,
  .is-embed .loading { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
  .drag-hint,
  .drag-hint__hand,
  .drag-hint__arrows { animation: none; }
}

/* Werkstatt-Ansicht (?werkstatt=1) */
.is-werkstatt .layout {
  display: block;
  height: auto;
  min-height: 0;
}
.is-werkstatt .stage {
  width: min(100%, 70svh);
  height: auto;
  aspect-ratio: 1 / 1;
  min-height: 0;
  max-height: 70svh;
  margin: 0 auto;
}
.is-werkstatt .panel,
.is-werkstatt .views,
.is-werkstatt .zoom { display: none; }

.werkstatt {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}
.werkstatt h1 { margin-bottom: 14px; }
.werkstatt dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 18px;
  margin: 0 0 22px;
}
.werkstatt dt { color: var(--muted); }
.werkstatt dd { margin: 0; overflow-wrap: anywhere; }
.werkstatt .lines {
  margin: 0;
  font: inherit;
  font-weight: 600;
  white-space: pre-wrap;
}
.werkstatt .note { margin: 0; color: var(--muted); font-size: 13px; }
