.helix-picker {
  container: helix / inline-size;
}

.helix-picker [hidden] {
  display: none !important;
}

[data-helix-live] {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.helix-product-picker {
  margin-top: 24px;
}

.helix-feedback {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 0 16px;
}

.helix-desktop,
.helix-selection {
  display: none;
}

.helix-axis {
  margin: 0 0 6px;
}

.helix-diameters,
.helix-sizes {
  display: grid;
  gap: 8px;
}

.helix-diameters {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 52px), 1fr));
  margin-bottom: 12px;
}

.helix-sizes {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.helix-diameter,
.helix-tile {
  min-width: 0;
  min-height: 44px;
  padding: 6px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--bg);
  font: inherit;
}

.helix-diameter strong,
.helix-diameter small,
.helix-tile strong,
.helix-tile small {
  display: block;
}

.helix-diameter {
  display: grid;
  place-content: center;
  gap: 3px;
  padding-inline: 2px;
  text-align: center;
  overflow-wrap: anywhere;
}

.helix-diameter strong {
  font-size: 14px;
  line-height: 1.2;
}

.helix-diameter small {
  min-height: 1.2em;
  font-size: 11px;
  line-height: 1.2;
}

.helix-tile {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-inline: 10px;
  min-height: 54px;
  text-align: left;
  width: 100%;
  overflow-wrap: anywhere;
}

.helix-tile .helix-sku {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.helix-tile:disabled {
  background: var(--surface);
  color: var(--muted);
  opacity: 1;
}

.helix-tile-content {
  display: grid;
  justify-items: start;
  flex: 1;
  min-width: 0;
  gap: 3px;
}

.helix-tile-photo {
  display: block;
  width: min(100%, 96px);
  height: auto;
  aspect-ratio: 1;
  object-fit: contain;
  justify-self: center;
  margin-block: 2px 4px;
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.helix-option {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 4px;
}

.helix-option > a {
  justify-self: start;
  padding: 3px 4px;
}

.helix-tile-check {
  flex: 0 0 18px;
  width: 18px;
  height: 18px;
  fill: none;
  stroke: var(--action);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.helix-tile-check path {
  stroke-dasharray: 1 1;
  stroke-dashoffset: 1;
  opacity: 0;
}

.helix-tile[aria-pressed=true] .helix-tile-check path {
  stroke-dashoffset: 0;
  opacity: 1;
}

@media (prefers-reduced-motion: no-preference) {
  .helix-tile {
    transition: background-color 200ms ease-out, border-color 200ms ease-out;
  }

  .helix-tile-check path {
    transition: stroke-dashoffset 200ms cubic-bezier(0.2, 0.65, 0.35, 1), opacity 120ms ease-out;
  }
}

.helix-diameter[aria-pressed=true],
.helix-tile[aria-pressed=true] {
  background: #e0f1ec;
  color: #195a4c;
  border-color: var(--action);
}

.helix-diameter:hover,
.helix-tile:not(:disabled):hover {
  border-color: var(--action);
}

.helix-bottom {
  position: fixed;
  inset: auto 0 0;
  z-index: 10;
  padding: 10px max(16px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.helix-bottom .btn {
  display: flex;
  width: 100%;
  justify-content: space-between;
  gap: 8px;
  min-height: 44px;
}

body:has(.helix-bottom:not([hidden])) {
  padding-bottom: 68px;
}

.helix-dialog {
  inset: auto 0 0;
  margin: 0 auto;
  width: min(100%, 560px);
  max-width: none;
  max-height: 90dvh;
  padding: 16px 16px max(16px, env(safe-area-inset-bottom));
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  color: var(--text);
  background: var(--surface);
  overscroll-behavior: contain;
}

.helix-dialog[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.helix-dialog [data-helix-selection] {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  min-height: 0;
}

.helix-dialog .helix-lines {
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 4px;
  margin-inline: -4px;
}

.helix-dialog::backdrop {
  background: rgb(23 45 58 / 50%);
}

.helix-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 8px;
}

.helix-dialog-header .btn {
  min-width: 44px;
  min-height: 44px;
  padding: 4px;
  font-size: 20px;
}

.helix-dialog-header p,
.helix-selection > p {
  margin: 2px 0 0;
}

.helix-lines {
  list-style: none;
  padding: 0;
  margin: 0;
}

.helix-lines li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 3px 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.helix-lines p {
  margin: 0;
}

.helix-line-stock,
.helix-line-delivery {
  grid-column: 1 / -1;
}

.helix-line-name a {
  font-weight: 600;
}

.helix-line-name .small {
  line-height: 1.25;
}

.helix-line-total {
  text-align: right;
  white-space: nowrap;
}

.helix-line-controls {
  display: flex;
  align-items: center;
  gap: 2px;
}

.helix-line-controls .btn,
.helix-line-controls input[data-helix-quantity] {
  flex: 0 0 44px;
  width: 44px;
  min-width: 0;
  min-height: 44px;
  padding: 0;
  text-align: center;
}

.helix-line-controls input[data-helix-quantity] {
  font-variant-numeric: tabular-nums;
  appearance: textfield;
}

.helix-line-controls input::-webkit-inner-spin-button {
  appearance: none;
}

.helix-line-controls .helix-remove {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.helix-line-controls .helix-remove:hover {
  color: var(--danger);
}

.helix-summary {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-top: 12px;
}

.helix-summary span {
  display: block;
}

.helix-summary strong {
  font-size: 22px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.helix-add {
  width: 100%;
  min-height: 44px;
  margin-top: 8px;
}

.helix-empty {
  margin-top: 12px;
}

@container helix (min-width: 720px) {
  .helix-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(286px, 1fr);
    align-items: start;
    gap: 20px;
  }

  .helix-desktop,
  .helix-selection {
    display: block;
  }

  .helix-mobile,
  .helix-bottom {
    display: none;
  }

  .helix-selection {
    border-inline-start: 1px solid var(--border);
    padding-inline-start: 16px;
  }

  .helix-matrix-scroll {
    overflow-x: auto;
    padding: 2px;
  }

  .helix-matrix {
    border-collapse: separate;
    border-spacing: 4px;
    width: 100%;
    text-align: center;
  }

  .helix-matrix th,
  .helix-matrix td {
    border: 0;
    padding: 0;
    vertical-align: middle;
    background: transparent;
  }

  .helix-matrix th[rowspan] {
    width: 64px;
  }

  .helix-matrix td {
    min-width: 104px;
  }

  .helix-matrix :is(th[scope=row], th[rowspan]) {
    text-align: left;
  }

  .helix-matrix .helix-tile {
    padding-inline: 4px 8px;
    text-align: center;
    min-height: 44px;
  }

  .helix-matrix .helix-tile-content {
    justify-items: center;
  }

  .helix-matrix .helix-tile-photo {
    width: min(100%, 52px);
  }

  .helix-matrix .helix-tile .helix-sku {
    font-size: 12px;
  }

  .helix-matrix .helix-tile-price {
    font-size: 0.6875rem;
    white-space: nowrap;
  }

  .helix-missing {
    color: var(--muted);
  }

  .helix-size-group + .helix-size-group {
    margin-top: 12px;
  }

  .helix-size-group h3 {
    margin-bottom: 6px;
  }
}

@media (min-width: 1000px) {
  body:has(.helix-bottom:not([hidden])) {
    padding-bottom: 0;
  }
}
