.stvnsg {
  margin-top: 10px;
}

.stvnsg--right {
  margin-top: 0;
  display: flex;
  justify-content: flex-end;
}

/* Inline placement when the Size Guide is moved next to a variant label */
.stvnsg--inline {
  margin: 0;
  display: inline-flex;
  align-items: center;
  margin-left: auto;
  margin-top: 0;
}

.stvnsg__variant-label {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}

/* WCPA layouts sometimes make label a flex-item; force full-row behavior */
.wcpa_form_item.shirt-size_parent > label.stvnsg__variant-label,
.wcpa_form_item > label.stvnsg__variant-label {
  display: flex !important;
  width: 100% !important;
  max-width: 100% !important;
  flex: 1 1 100% !important;
  box-sizing: border-box;
}

.stvnsg__label-text {
  min-width: 0;
  flex: 1 1 auto;
}

.stvnsg--inline .stvnsg__button--link {
  white-space: nowrap;
}

.stvnsg__button {
  cursor: pointer;
  margin: 0;
  margin-bottom: 0;
}

.stvnsg__button--link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 0;
  padding: 0;
  font-size: 0.9em;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.stvnsg__icon {
  display: inline-flex;
  align-items: center;
  color: var(--stvnsg-icon-color, currentColor);
}

.stvnsg__label {
  color: var(--stvnsg-text-color, inherit);
}

.stvnsg__dialog {
  width: min(720px, calc(100% - 24px));
  border: none;
  padding: 0;
  border-radius: 18px;
  box-sizing: border-box;
  max-height: calc(100vh - 24px);
  overflow: auto;
}

@media (min-width: 769px) {
  dialog.stvnsg__dialog[open] {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
  }
}

.stvnsg__dialog::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.stvnsg__header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 16px 16px 0 16px;
  position: relative;
}

.stvnsg__title {
  margin: 0;
  font-size: 18px;
  text-align: center;
  width: 100%;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.stvnsg__close {
  cursor: pointer;
  border: 0;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  position: absolute;
  right: 12px;
  top: 12px;
  margin: 0;
  margin-bottom: 0;
}

.stvnsg__body {
  padding: 16px;
}

.stvnsg__find {
  display: block;
  text-align: center;
  margin: 0 0 14px;
}

.stvnsg__find-title {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.02em;
  margin: 0 0 14px;
  text-transform: uppercase;
}

.stvnsg__unit-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  background: #e9e9e9;
  border-radius: 999px;
  width: min(320px, 100%);
  box-sizing: border-box;
  margin: 0 auto;
}

.stvnsg__unit-btn {
  cursor: pointer;
  border: 0;
  background: transparent;
  padding: 10px 22px;
  border-radius: 999px;
  font-weight: 700;
  flex: 1 1 0;
  min-width: 0;
  text-align: center;
  margin: 0;
  margin-bottom: 0;
}

.stvnsg__unit-btn[aria-pressed="true"] {
  background: #4b4f56;
  color: #fff;
}

.stvnsg__measure {
  margin: 0 0 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  text-align: center;
}

.stvnsg__measure-img {
  display: block;
  margin: 0 auto;
  width: 100%;
  max-width: 480px;
  max-height: 320px;
  height: auto;
  object-fit: contain;
}

.stvnsg-table-frontend__wrap {
  overflow-x: auto;
}

.stvnsg-table-frontend {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
}

.stvnsg-table-frontend th,
.stvnsg-table-frontend td {
  border: 0;
  padding: 14px 12px;
  text-align: center;
}

.stvnsg-table-frontend thead th {
  background: transparent;
  font-weight: 800;
  letter-spacing: 0.02em;
  font-size: 15px;
}

.stvnsg-table-frontend tbody tr:nth-child(odd) {
  background: #f2f2f2;
}

.stvnsg-table-frontend tbody th[scope="row"] {
  font-weight: 800;
}

.stvnsg-table-frontend__caption {
  margin: 8px 0 0;
  font-size: 12px;
  color: #666;
}

@media (max-width: 768px) {
  .stvnsg__dialog {
    --stvnsg-mobile-extra-top: 18px;
    width: 100vw;
    max-width: 100vw;
    max-height: calc(100vh - var(--stvnsg-top-offset, 12px) - var(--stvnsg-mobile-extra-top, 18px) - 12px);
    margin: 0;
    border-radius: 18px;
    overflow: auto;
  }

  .stvnsg__dialog[open] {
    position: fixed;
    left: 0;
    right: 0;
    top: calc(var(--stvnsg-top-offset, 12px) + var(--stvnsg-mobile-extra-top, 18px) + env(safe-area-inset-top, 0px));
    transform: none;
  }

  .stvnsg__header {
    padding: 14px 12px 0 12px;
  }

  .stvnsg__title {
    font-size: 16px;
  }

  .stvnsg__close {
    right: 6px;
    top: 6px;
    font-size: 26px;
  }

  .stvnsg__body {
    padding: 10px;
  }

  .stvnsg__find {
    padding: 12px 0 6px;
  }

  .stvnsg__find-title {
    font-size: 22px;
    margin-bottom: 12px;
  }

  .stvnsg__unit-toggle {
    padding: 3px;
  }

  .stvnsg__unit-btn {
    padding: 8px 16px;
    min-width: 80px;
    font-size: 13px;
  }

  .stvnsg__measure {
    margin-bottom: 10px;
  }

  .stvnsg__measure-img {
    max-width: 320px;
    max-height: 240px;
  }

  .stvnsg__button--link {
    gap: 6px;
    letter-spacing: 0.01em;
  }

  .stvnsg-table-frontend__wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .stvnsg-table-frontend {
    table-layout: fixed;
    width: 100%;
  }

  .stvnsg-table-frontend th,
  .stvnsg-table-frontend td {
    padding: 10px 8px;
    font-size: 13px;
    line-height: 1.35;
    white-space: normal;
    word-break: break-word;
    hyphens: auto;
  }

  .stvnsg-table-frontend thead th {
    letter-spacing: 0.01em;
    font-size: 13px;
  }

  .stvnsg-table-frontend__caption {
    font-size: 11px;
  }
}

@media (max-width: 768px) {
  /* Fallback styling when <dialog> isn't fully supported */
  .stvnsg__dialog--open {
    left: 0;
    right: 0;
    top: calc(var(--stvnsg-top-offset, 12px) + var(--stvnsg-mobile-extra-top, 20px) + env(safe-area-inset-top, 0px));
    bottom: auto;
    margin: 0;
    max-height: calc(100vh - var(--stvnsg-top-offset, 12px) - var(--stvnsg-mobile-extra-top, 20px) - 12px);
    border-radius: 18px;
  }
}

/* Fallback styling when <dialog> isn't fully supported */
.stvnsg__dialog--open {
  position: fixed;
  inset: 0;
  margin: auto;
  background: #fff;
  z-index: 999999;
  max-height: calc(100vh - 24px);
  overflow: auto;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  border-radius: 18px;
}
