* { box-sizing: border-box; }
:root { color: #231d30; background: #f8f5ef; font-family: system-ui, "Segoe UI", sans-serif; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; }
button, select { font: inherit; }
a, button, select { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #6844b7; outline-offset: 3px; }
.masthead { padding: 16px max(5vw, calc((100vw - 1220px)/2)); border-bottom: 1px solid #e9e2da; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.masthead a { color: #4d337c; font-weight: 680; font-size: .9rem; }
.wordmark { display: flex; align-items: center; gap: 9px; font-weight: 850; letter-spacing: -.04em; }
.masthead .wordmark { color: #231d30; font-weight: 850; text-decoration: none; }
.wordmark .brand-mark { display: block; flex: none; width: 36px; height: 36px; }
main { max-width: 1280px; padding: clamp(25px, 5vw, 58px) max(20px, 4vw); margin: auto; }
.intro { margin-bottom: 26px; }
h1 { font-size: clamp(2.35rem, 6vw, 4.25rem); line-height: .98; letter-spacing: -.075em; }
h1 span { color: #8254cd; }
.intro p { color: #62586b; margin-top: 12px; }
.layout { display: grid; grid-template-columns: minmax(0, 1.52fr) minmax(330px, 1fr); gap: 20px; align-items: start; }
.preview { position: sticky; top: 18px; border-radius: 22px; overflow: hidden; background: #e7ddfc; border: 1px solid #dcd0f5; }
.preview-head { display: flex; justify-content: space-between; align-items: center; padding: 19px 22px 0; gap: 10px; }
.preview-head h2, .editor h2 { font-size: 1.15rem; letter-spacing: -.03em; }
#piece-count { color: #54466b; font-size: .875rem; }
.stage { display: grid; place-items: center; min-height: 315px; height: clamp(315px, 35vw, 440px); padding: 15px; isolation: isolate; position: relative; background: radial-gradient(ellipse at 48% 50%, #f8f0ff 0%, transparent 62%); }
.stage::before { content: ""; position: absolute; z-index: -1; width: 72%; height: 54%; border: 1px dashed #b9a7dc; border-radius: 50%; transform: rotate(-15deg); }
.model { display: flex; width: min(95%, 485px); align-items: center; justify-content: center; gap: clamp(2px, .6vw, 7px); transform: rotate(-12deg); filter: drop-shadow(0 19px 12px #63488545); }
.hardware { flex: 0 1 78px; min-width: 25px; display: block; z-index: 1; overflow: visible; height: auto; aspect-ratio: 68 / 44; }
.hardware-right { transform: scaleX(-1); }
.hardware-shape { stroke-width: 2.65; filter: drop-shadow(0 .75px .6px #32263f33); }
.cap { display: grid; flex: 0 1 calc(88% / var(--count)); max-width: 61px; min-width: 0; padding: 0; border: 0; aspect-ratio: 1; place-items: center; border-radius: 24%; background: transparent; position: relative; isolation: isolate; }
.cap[aria-pressed=true] { outline: 2px solid #6844b7; outline-offset: 2px; }
.cap:focus-visible { outline: 3px solid #482477; outline-offset: 4px; }
.cap-rim,
.cap::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.cap-rim {
  z-index: 0;
  border-radius: inherit;
  background: linear-gradient(145deg, #fff4, transparent 50%, #0002), var(--base);
  box-shadow: inset 0 1px 2px #fff8, inset 0 0 0 1px #0002;
}
.cap.ribbed .cap-rim {
  border-radius: 0;
  clip-path: var(--ribbed-shape);
  background: linear-gradient(145deg, #fff5, transparent 48%, #0002), var(--base);
  box-shadow: none;
}
.cap::after {
  content: "";
  transform: translateY(22%);
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(180deg, transparent 69%, #0004), var(--edge);
}
.cap.ribbed::after {
  clip-path: var(--ribbed-shape);
  border-radius: 0;
  background:
    linear-gradient(180deg, transparent 69%, #0004),
    repeating-linear-gradient(90deg, #0003 0%, transparent 3%, #fff3 6%, transparent 9%, #0003 12%),
    var(--edge);
}
.cap::before { content: ""; position: absolute; inset: 15%; z-index: 1; background: linear-gradient(145deg,#fff4,#0001) var(--top); border-radius: 24%; box-shadow: inset 0 1px 1px #fff5, 0 2px 2px #0005; }
.cap.ribbed::before {
  inset: 15%;
  z-index: 1;
  background: linear-gradient(150deg, #fff5, transparent 55%, #0002) var(--top);
  box-shadow: inset 0 1px 1px #fff4, 0 2px 2px #0004;
}
.mount { position: absolute; top: 39%; width: 20%; height: 28%; border: 2px solid var(--edge); background: var(--base); border-radius: 38%; z-index: -1; }
.mount::after { content: ""; position: absolute; inset: 24%; background: #e7ddfc; border-radius: 50%; }
.mount-left { right: 94%; }
.mount-right { left: 94%; }
.cap span { z-index: 2; color: var(--ink); font-size: clamp(.9rem, 3.1vw, 2rem); font-weight: 950; line-height: 1; text-shadow: 0 1px 0 #0003; }
.cap svg, .pieces svg { display: block; width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.preview-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px 14px; flex-wrap: wrap; padding: 0 20px 18px; }
.preview-note { font-size: .84rem; color: #55496b; }
#preview-price { color: #392556; white-space: nowrap; font-size: .95rem; }
.editor { background: #fffdf9; padding: clamp(15px, 3vw, 24px); border: 1px solid #e8e0d9; border-radius: 22px; }
.custom-steps { display: grid; gap: 7px; margin-top: 12px; }
.custom-step { border: 1px solid #e8e0e9; border-radius: 11px; }
.custom-step[open] { border-color: #d9c8ed; }
.custom-step > summary { display: flex; align-items: center; gap: 8px; padding: 11px; min-height: 44px; list-style: none; cursor: pointer; font-weight: 700; }
.custom-step > summary::-webkit-details-marker { display: none; }
.custom-step > summary::after { content: '+'; margin-left: auto; color: #6844b7; font-weight: 800; }
.custom-step[open] > summary::after { content: '−'; }
.step-meta { color: #62586b; font-size: .85rem; font-weight: 500; }
.step-body { padding: 0 11px 11px; }
.step-next { width: 100%; margin-top: 12px; background: #f1eaf6; }
#review-montage { margin: 2px 0 5px; font-weight: 750; overflow-wrap: anywhere; }
#review-rings { color: #62586b; font-size: .875rem; }
.name-form label { display: block; font-weight: 700; margin-bottom: 6px; }
.name-form input { width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid #b7a3cb; border-radius: 8px; color: inherit; background: #fff; font: inherit; }
.name-form .step-next { background: #503379; color: white; }
.name-error { margin-top: 6px; color: #a02740; font-size: .85rem; }
.preset-options { margin-top: 14px; }
.preset-options > summary { cursor: pointer; color: #503379; font-weight: 700; }
.preset-options .presets { margin-top: 8px; }

.presets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.presets button { min-height: 40px; padding-inline: 4px; background: #f1eaf6; font-size: .875rem; }
.ring-picker { display: grid; gap: 6px; margin-bottom: 8px; }
.hardware-picker { display: grid; gap: 8px; }
.hardware-picker label { display: grid; gap: 5px; }
.hardware-picker [hidden] { display: none; }
button { cursor: pointer; border: 1px solid #ddd2e6; background: #fffdf9; color: #392c4f; padding: 7px 10px; border-radius: 8px; font-weight: 650; }
button:disabled { opacity: .48; cursor: default; }
.section-title, .piece-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.section-title { justify-content: space-between; }
h3 { font-size: 1rem; }
.hint { margin: 5px 0 9px; color: #62586b; font-size: .875rem; }
.pieces { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 13px; }
.pieces button { min-width: 32px; background: var(--chip); color: #251e2d; }
.pieces button[aria-pressed=true] { outline: 2px solid #6844b7; outline-offset: 1px; }
fieldset { display: grid; grid-template-columns: minmax(0, 1fr) minmax(115px, 1fr); align-items: center; gap: 8px; margin: 0; padding: 10px; border: 1px solid #e8e0e9; border-radius: 10px; }
legend, label { font-size: .875rem; font-weight: 650; }
.layer-title { grid-column: 1 / -1; font-size: .95rem; padding-top: 3px; }
select { width: 100%; min-width: 0; color: #231d30; padding: 6px; border: 1px solid #d8cddd; background: #fff; border-radius: 6px; }
.piece-actions { grid-column: 1 / -1; margin-top: 2px; }
#remove-piece { margin-left: auto; }
.clicker-price { color: #392556; font-weight: 800; font-size: 1.25rem; margin-top: 14px; }
.order-actions { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 8px; margin-top: 16px; }
.order { min-height: 46px; padding: 9px 8px; border: 0; border-radius: 9px; background: #236247; color: white; font-size: .9rem; font-weight: 750; }
.order-buy { background: #4f3280; }
.clicker-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
[data-cart-link] { display: inline-flex; align-items: center; gap: 6px; }
[data-cart-link] svg { flex: none; }
.order-note a { color: #4d337c; font-weight: 700; }
.order-note { color: #62586b; font-size: .84rem; margin-top: 7px; }
#examples { margin-top: 36px; }
#examples h2 { margin-bottom: 14px; font-size: 1.4rem; }
.example-photos { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 14px; }
.example-photos a { display: block; }
.example-photos img { display: block; width: 100%; height: clamp(230px, 32vw, 390px); object-fit: contain; border: 1px solid #e8e0d9; border-radius: 14px; background: #fffdf9; }
@media (max-width: 760px) {
  .layout { grid-template-columns: 1fr; }
  .preview { top: 4px; z-index: 2; }
  .stage { height: clamp(110px, 34vw, 220px); min-height: 0; }
  #piece-editor, .custom-step > summary { scroll-margin-top: calc(clamp(110px, 34vw, 220px) + 125px); }
  .cap span { font-size: clamp(.85rem, 4vw, 1.8rem); }
}
@media (max-width: 540px) {
  .masthead { flex-direction: column; align-items: stretch; gap: 8px; padding: 12px 5vw; }
  .masthead .wordmark { align-self: center; min-height: 44px; }
  .clicker-nav { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .clicker-nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 6px;
    border: 1px solid #e0d3ec;
    border-radius: 8px;
    background: #f1eaf6;
    text-align: center;
    text-decoration: none;
  }
  .clicker-nav a:focus-visible { outline: 2px solid #6844b7; outline-offset: 2px; }
}
