.ice-diy {
  --ice-diy-ink: #111111;
  --ice-diy-muted: #686868;
  --ice-diy-line: #dedede;
  --ice-diy-soft: #f7f7f7;
  --ice-diy-accent: #d89a18;
  color: var(--ice-diy-ink);
  padding: 56px 24px 24px;
}

.ice-diy__header {
  align-items: center;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(120px, 1fr) minmax(220px, auto) minmax(220px, 1fr);
}

.ice-diy__back {
  color: var(--ice-diy-ink);
  font-size: 15px;
  font-weight: 600;
}

.ice-diy__heading {
  min-width: 0;
  text-align: center;
}

.ice-diy__title {
  color: var(--ice-diy-ink);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.2;
  margin: 0;
  text-wrap: balance;
}

.ice-diy__subtitle {
  color: var(--ice-diy-muted);
  font-size: 15px;
  line-height: 1.4;
  margin: 4px 0 0;
  text-wrap: pretty;
}

.ice-diy__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.ice-diy__button,
.ice-diy__type-button {
  align-items: center;
  border-radius: 8px;
  display: inline-flex;
  font-size: 14px;
  font-weight: 600;
  justify-content: center;
  line-height: 1.2;
  min-height: 40px;
  padding: 10px 16px;
}

.ice-diy__button--primary {
  background: #000000;
  color: #ffffff;
}

.ice-diy__button--ghost,
.ice-diy__type-button {
  background: #ffffff;
  border: 1px solid var(--ice-diy-line);
  color: var(--ice-diy-ink);
}

.ice-diy__type {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}

.ice-diy__type[hidden] {
  display: none;
}

.ice-diy__type-button.is-active {
  border-color: var(--ice-diy-accent);
}

.ice-diy__layout {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 36%);
  margin-top: 20px;
}

.ice-diy__stage,
.ice-diy__library,
.ice-diy__summary {
  background: #ffffff;
  border: 1px solid var(--ice-diy-line);
  border-radius: 8px;
}

.ice-diy__toolbar {
  align-items: center;
  border-bottom: 1px solid var(--ice-diy-line);
  color: var(--ice-diy-muted);
  display: flex;
  font-size: 13px;
  gap: 12px;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 14px;
}

.ice-diy__canvas {
  aspect-ratio: 16 / 9;
  background: var(--ice-diy-soft);
  overflow: hidden;
  position: relative;
  width: 100%;
}

.ice-diy__board {
  inset: 0;
  position: absolute;
  transform-origin: center;
}

.ice-diy__library {
  min-height: 464px;
  overflow: hidden;
}

.ice-diy__panel-head {
  border-bottom: 1px solid var(--ice-diy-line);
  padding: 16px;
}

.ice-diy__panel-head h2,
.ice-diy__summary h2 {
  color: var(--ice-diy-ink);
  font-size: 16px;
  font-weight: 700;
  line-height: 1.25;
  margin: 0;
}

.ice-diy__library-body {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.ice-diy__empty {
  color: var(--ice-diy-muted);
  font-size: 14px;
  line-height: 1.45;
  margin: 0;
}

.ice-diy__group h3 {
  color: var(--ice-diy-ink);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 10px;
}

.ice-diy__parts {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
}

.ice-diy__base-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(142px, 1fr));
}

.ice-diy__part,
.ice-diy__base-card {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--ice-diy-line);
  border-radius: 8px;
  color: var(--ice-diy-ink);
  cursor: grab;
  display: grid;
  gap: 6px;
  justify-items: center;
  min-height: 126px;
  padding: 10px;
  text-align: center;
  touch-action: none;
}

.ice-diy__base-card {
  cursor: pointer;
  min-height: 148px;
}

.ice-diy__part:disabled,
.ice-diy__base-card:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.ice-diy__part img,
.ice-diy__base-card img {
  -webkit-user-drag: none;
  aspect-ratio: 1;
  height: 64px;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  width: 64px;
}

.ice-diy__part-title,
.ice-diy__part-price {
  display: block;
  font-size: 12px;
  line-height: 1.25;
}

.ice-diy__part-price {
  color: var(--ice-diy-muted);
  font-variant-numeric: tabular-nums;
}

.ice-diy__base-kind {
  color: var(--ice-diy-muted);
  display: block;
  font-size: 11px;
  line-height: 1.2;
  text-transform: uppercase;
}

.ice-diy__selected-base {
  align-items: center;
  border: 1px solid var(--ice-diy-line);
  border-radius: 8px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 10px;
}

.ice-diy__selected-base-info {
  align-items: center;
  display: flex;
  gap: 10px;
  min-width: 0;
}

.ice-diy__selected-base-info img {
  -webkit-user-drag: none;
  aspect-ratio: 1;
  height: 42px;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  width: 42px;
}

.ice-diy__selected-base-info span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.ice-diy__selected-base-info strong,
.ice-diy__selected-base-info small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ice-diy__selected-base-info strong {
  font-size: 13px;
  line-height: 1.25;
}

.ice-diy__selected-base-info small {
  color: var(--ice-diy-muted);
  font-size: 11px;
  line-height: 1.2;
}

.ice-diy__slot {
  background: #ffffff;
  border: 1px solid #a8a8a8;
  border-radius: 50%;
  display: none !important;
  height: 18px;
  pointer-events: none;
  position: absolute;
  transform: translate(-50%, -50%);
  width: 18px;
  z-index: 1;
}

.ice-diy__placed {
  position: absolute;
  transform: translate(-50%, calc(-50% - var(--ice-diy-placed-y-offset, 0px))) scale(var(--ice-diy-placed-scale, 1));
  transform-origin: center;
  z-index: 3;
}

.ice-diy__placed img {
  aspect-ratio: 1;
  height: var(--ice-diy-part-size, 72px);
  object-fit: contain;
  width: var(--ice-diy-part-size, 72px);
}

.ice-diy__placed[data-diy-sized="true"] img {
  aspect-ratio: auto;
  height: auto;
  max-width: none;
  width: 100%;
}

.ice-diy__placed--chain {
  z-index: 1;
}

.ice-diy__placed--chain img {
  aspect-ratio: auto;
  height: auto;
  max-width: min(58vw, 560px);
  width: 46vw;
}

.ice-diy__placed--pendant_base {
  z-index: 2;
}

.ice-diy__placed--pendant_base img {
  aspect-ratio: auto;
  height: auto;
  max-width: min(46vw, 430px);
  width: 36vw;
}

.ice-diy__placed--connector {
  z-index: 4;
}

.ice-diy__placed--connector img {
  aspect-ratio: auto;
  height: auto;
  max-width: 150px;
  width: 13vw;
}

.ice-diy__placed--pendant_stone,
.ice-diy__placed--chain_stone,
.ice-diy__placed--chain_charm {
  z-index: 5;
}

.ice-diy__placed--pendant_stone img,
.ice-diy__placed--chain_stone img {
  height: 34px;
  width: 34px;
}

.ice-diy__placed--chain_charm img {
  height: 52px;
  width: 52px;
}

.ice-diy__placed.is-removable {
  cursor: pointer;
}

.ice-diy__placed.is-removable:hover img,
.ice-diy__placed.is-removable:focus-visible img {
  filter: drop-shadow(0 0 8px rgb(216 154 24 / 46%));
}

.ice-diy__placed[data-diy-sized="true"] img {
  aspect-ratio: auto;
  height: auto;
  max-width: none;
  width: 100%;
}

.ice-diy__placed[data-diy-fixed-width="true"] img {
  aspect-ratio: auto;
  height: auto;
  max-width: none;
  width: 100%;
}

.ice-diy__placed[data-diy-fixed-height="true"] img {
  height: 100%;
  object-fit: contain;
  width: 100%;
}

.ice-diy__placed[data-diy-fixed-size="true"] img {
  aspect-ratio: 1;
  height: var(--ice-diy-part-size, 18px) !important;
  max-width: none;
  width: var(--ice-diy-part-size, 18px) !important;
}

.ice-diy__placed[data-diy-fixed-shape="true"] {
  height: var(--ice-diy-part-height, 18px);
  overflow: hidden;
  width: var(--ice-diy-part-width, 18px);
}

.ice-diy__placed[data-diy-fixed-shape="true"] img {
  aspect-ratio: auto;
  display: block;
  height: 100% !important;
  max-width: none;
  object-fit: cover;
  width: 100% !important;
}

.ice-diy__photo-frame {
  background: #f1f1f1;
  border-radius: 999px;
  cursor: move;
  overflow: hidden;
  position: absolute;
  touch-action: none;
  transform: translate(-50%, -50%);
  z-index: 3;
}

.ice-diy__photo-frame img {
  -webkit-user-drag: none;
  display: block;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  transform: translate(var(--ice-diy-photo-x, 0), var(--ice-diy-photo-y, 0)) scale(var(--ice-diy-photo-scale, 1));
  transform-origin: center;
  user-select: none;
  width: 100%;
}

.ice-diy__placed.is-shape-circle,
.ice-diy__photo-frame.is-shape-circle {
  border-radius: 999px;
}

.ice-diy__placed.is-shape-oval,
.ice-diy__photo-frame.is-shape-oval {
  border-radius: 999px;
}

.ice-diy__placed.is-shape-square,
.ice-diy__photo-frame.is-shape-square {
  border-radius: 0;
}

.ice-diy__placed.is-shape-rounded-square,
.ice-diy__photo-frame.is-shape-rounded-square {
  border-radius: 18%;
}

.ice-diy__placed.is-shape-rectangle,
.ice-diy__photo-frame.is-shape-rectangle {
  border-radius: 3px;
}

.ice-diy__placed.is-shape-heart,
.ice-diy__photo-frame.is-shape-heart {
  border-radius: 0;
  clip-path: polygon(50% 92%, 12% 55%, 8% 32%, 24% 12%, 50% 24%, 76% 12%, 92% 32%, 88% 55%);
}

.ice-diy__placed.is-shape-teardrop,
.ice-diy__photo-frame.is-shape-teardrop {
  border-radius: 0;
  clip-path: polygon(50% 0%, 78% 18%, 96% 52%, 50% 100%, 4% 52%, 22% 18%);
}

.ice-diy__photo-crop {
  border: 1px solid var(--ice-diy-line);
  border-radius: 8px;
  padding: 12px;
}

.ice-diy__photo-upload {
  align-items: center;
  border: 1px dashed var(--ice-diy-line);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  font-size: 13px;
  font-weight: 700;
  justify-content: center;
  min-height: 44px;
  padding: 10px;
}

.ice-diy__photo-upload input {
  display: none;
}

.ice-diy__photo-controls {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.ice-diy__photo-controls label {
  align-items: center;
  color: var(--ice-diy-muted);
  display: grid;
  font-size: 12px;
  gap: 6px;
  grid-template-columns: 48px minmax(0, 1fr);
}

.ice-diy__photo-controls input {
  width: 100%;
}

.ice-diy__summary {
  align-items: flex-start;
  display: flex;
  gap: 16px;
  justify-content: space-between;
  margin-top: 16px;
  padding: 16px;
}

.ice-diy__summary ul {
  color: var(--ice-diy-muted);
  font-size: 14px;
  line-height: 1.5;
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}

.ice-diy__total {
  color: var(--ice-diy-ink);
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  white-space: nowrap;
}

.ice-diy__dialog {
  border: 1px solid var(--ice-diy-line);
  border-radius: 8px;
  color: var(--ice-diy-ink);
  max-width: min(420px, calc(100vw - 32px));
  padding: 20px;
}

.ice-diy__dialog::backdrop {
  background: rgb(0 0 0 / 38%);
}

.ice-diy__dialog p {
  color: var(--ice-diy-ink);
  font-size: 15px;
  line-height: 1.5;
  margin: 0;
  text-wrap: pretty;
}

.ice-diy__dialog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 18px;
}

@media (max-width: 900px) {
  .ice-diy {
    padding: max(32px, calc(env(safe-area-inset-top) + 24px)) 16px max(96px, calc(env(safe-area-inset-bottom) + 84px));
  }

  .ice-diy__header,
  .ice-diy__layout {
    grid-template-columns: 1fr;
  }

  .ice-diy__stage {
    position: sticky;
    top: max(8px, env(safe-area-inset-top));
    z-index: 20;
  }

  .ice-diy__header {
    gap: 12px;
  }

  .ice-diy__heading {
    text-align: left;
  }

  .ice-diy__title {
    font-size: 26px;
    line-height: 1.15;
  }

  .ice-diy__actions {
    display: grid;
    gap: 8px;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-content: stretch;
  }

  .ice-diy__button {
    min-height: 44px;
    padding: 10px 8px;
    width: 100%;
  }

  .ice-diy__canvas {
    aspect-ratio: auto;
    min-height: clamp(330px, 92vw, 430px);
  }

  .ice-diy__board {
    --ice-diy-mobile-board-scale: 1;
    --ice-diy-mobile-slot-scale: 1;
    --ice-diy-mobile-slot-y-offset: 0px;
    aspect-ratio: 16 / 9;
    bottom: auto;
    height: auto;
    left: 50%;
    right: auto;
    top: 50%;
    transform: translate(-50%, -50%) scale(var(--ice-diy-mobile-board-scale));
    width: 100%;
  }

  .ice-diy__placed--pendant_stone,
  .ice-diy__placed--chain_stone,
  .ice-diy__placed--chain_charm,
  .ice-diy__placed[data-diy-fixed-size="true"],
  .ice-diy__placed[data-diy-fixed-shape="true"] {
    --ice-diy-placed-scale: var(--ice-diy-mobile-slot-scale);
  }

  .ice-diy__placed--pendant_stone,
  .ice-diy__placed--chain_stone,
  .ice-diy__placed--chain_charm {
    --ice-diy-placed-y-offset: var(--ice-diy-mobile-slot-y-offset);
  }

  .ice-diy__selected-base {
    align-items: stretch;
    flex-direction: column;
  }

  .ice-diy__placed--chain img {
    max-width: 420px;
    width: 82vw;
  }

  .ice-diy__placed--pendant_base img {
    max-width: 310px;
    width: 66vw;
  }

  .ice-diy__placed--connector img {
    max-width: 110px;
    width: 22vw;
  }

  .ice-diy__placed[data-diy-fixed-width="true"] img {
    max-width: none;
    width: 100%;
  }

  .ice-diy__placed[data-diy-fixed-height="true"] img {
    height: 100%;
    object-fit: contain;
    width: 100%;
  }

  .ice-diy__summary {
    display: block;
  }

  .ice-diy__total {
    display: block;
    margin-top: 14px;
  }
}

@media (max-width: 430px) {
  .ice-diy__parts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ice-diy__part {
    min-height: 142px;
  }
}
